0001   0000             	device zxspectrum48
0002   0000             
0003   0000             
0004   0000             	org 32000-768
0005   7A00                    org 24832
0006   6100             
0007   6100             
0008   6100 C3 21 77           jp start
0009   6103             
0010   6103             
0011   6103             
0012   6103             WINDOWTOP equ 1
0013   6103             WINDOWLFT equ 1
0014   6103             WINDOWHGT equ 22
0015   6103             WINDOWWID equ 22 ;
0016   6103             MAPWID equ 5
0017   6103 FFFFFFFFFF         defb 255,255,255,255,255
0018   6108             mapdat equ $
0019   6108 FF000102FF         defb 255,0,1,2,255
0020   610D FFFFFFFFFF         defb 255,255,255,255,255
0021   6112 04          stmap  defb 4
0022   6113             evnt00 equ $
0023   6113 3E 07              ld a,7
0024   6115 E6 07              and 7
0025   6117 4F                 ld c,a
0026   6118 CD 7E 7A           call cspr
0027   611B 3A 2A 77           ld a,(joyval)
0028   611E E6 08              and 8
0029   6120 CA 38 61           jp z,a00065
0030   6123 CD 70 84           call laddu
0031   6126 C2 38 61           jp nz,a00065
0032   6129 3E 01              ld a,1
0033   612B DD 77 06           ld (ix+6),a
0034   612E AF                 xor a
0035   612F CD D2 89           call animsp
0036   6132 DD 35 08           dec (ix+8)
0037   6135 DD 35 08           dec (ix+8)
0038   6138 3A 2A 77    a00065 ld a,(joyval)
0039   613B E6 04              and 4
0040   613D CA 55 61           jp z,a00113
0041   6140 CD 60 84           call laddd
0042   6143 C2 55 61           jp nz,a00113
0043   6146 3E 01              ld a,1
0044   6148 DD 77 06           ld (ix+6),a
0045   614B AF                 xor a
0046   614C CD D2 89           call animsp
0047   614F DD 34 08           inc (ix+8)
0048   6152 DD 34 08           inc (ix+8)
0049   6155 3A 2A 77    a00113 ld a,(joyval)
0050   6158 E6 01              and 1
0051   615A CA 81 61           jp z,a00189
0052   615D CD E9 84           call cangr
0053   6160 C2 74 61           jp nz,a00165
0054   6163 AF                 xor a
0055   6164 DD 77 06           ld (ix+6),a
0056   6167 AF                 xor a
0057   6168 CD D2 89           call animsp
0058   616B DD 34 09           inc (ix+9)
0059   616E DD 34 09           inc (ix+9)
0060   6171 C3 81 61           jp a00189
0061   6174 AF          a00165 xor a
0062   6175 21 41 77           ld hl,vark
0063   6178 BE                 cp (hl)
0064   6179 D2 81 61           jp nc,a00189
0065   617C 3E 01              ld a,1
0066   617E CD BD 76           call dig
0067   6181 3A 2A 77    a00189 ld a,(joyval)
0068   6184 E6 02              and 2
0069   6186 CA AC 61           jp z,a00265
0070   6189 CD DE 84           call cangl
0071   618C C2 A0 61           jp nz,a00241
0072   618F AF                 xor a
0073   6190 DD 77 06           ld (ix+6),a
0074   6193 AF                 xor a
0075   6194 CD D2 89           call animsp
0076   6197 DD 35 09           dec (ix+9)
0077   619A DD 35 09           dec (ix+9)
0078   619D C3 AC 61           jp a00265
0079   61A0 AF          a00241 xor a
0080   61A1 21 41 77           ld hl,vark
0081   61A4 BE                 cp (hl)
0082   61A5 D2 AC 61           jp nc,a00265
0083   61A8 AF                 xor a
0084   61A9 CD BD 76           call dig
0085   61AC 3E 06       a00265 ld a,6
0086   61AE E6 07              and 7
0087   61B0 4F                 ld c,a
0088   61B1 CD 7E 7A           call cspr
0089   61B4 CD 39 85           call getcol
0090   61B7 C9                 ret
0091   61B8             evnt01 equ $
0092   61B8 AF                 xor a
0093   61B9 DD BE 0A           cp (ix+10)
0094   61BC C2 F6 61           jp nz,b00114
0095   61BF CD 70 84           call laddu
0096   61C2 C2 CE 61           jp nz,b00038
0097   61C5 DD 35 08           dec (ix+8)
0098   61C8 DD 35 08           dec (ix+8)
0099   61CB C3 F6 61           jp b00114
0100   61CE 3E 02       b00038 ld a,2
0101   61D0 57                 ld d,a
0102   61D1 CD 21 86           call random
0103   61D4 67                 ld h,a
0104   61D5 CD 4F 7F           call imul
0105   61D8 7C                 ld a,h
0106   61D9 32 53 77           ld (varrnd),a
0107   61DC AF                 xor a
0108   61DD 21 53 77           ld hl,varrnd
0109   61E0 BE                 cp (hl)
0110   61E1 C2 EC 61           jp nz,b00096
0111   61E4 3E 02              ld a,2
0112   61E6 DD 77 0A           ld (ix+10),a
0113   61E9 C3 F1 61           jp b00105
0114   61EC 3E 03       b00096 ld a,3
0115   61EE DD 77 0A           ld (ix+10),a
0116   61F1 3E 32       b00105 ld a,50
0117   61F3 DD 77 0B           ld (ix+11),a
0118   61F6 3E 01       b00114 ld a,1
0119   61F8 DD BE 0A           cp (ix+10)
0120   61FB C2 35 62           jp nz,b00225
0121   61FE CD 60 84           call laddd
0122   6201 C2 0D 62           jp nz,b00149
0123   6204 DD 34 08           inc (ix+8)
0124   6207 DD 34 08           inc (ix+8)
0125   620A C3 35 62           jp b00225
0126   620D 3E 02       b00149 ld a,2
0127   620F 57                 ld d,a
0128   6210 CD 21 86           call random
0129   6213 67                 ld h,a
0130   6214 CD 4F 7F           call imul
0131   6217 7C                 ld a,h
0132   6218 32 53 77           ld (varrnd),a
0133   621B AF                 xor a
0134   621C 21 53 77           ld hl,varrnd
0135   621F BE                 cp (hl)
0136   6220 C2 2B 62           jp nz,b00207
0137   6223 3E 02              ld a,2
0138   6225 DD 77 0A           ld (ix+10),a
0139   6228 C3 30 62           jp b00216
0140   622B 3E 03       b00207 ld a,3
0141   622D DD 77 0A           ld (ix+10),a
0142   6230 3E 32       b00216 ld a,50
0143   6232 DD 77 0B           ld (ix+11),a
0144   6235 3E 02       b00225 ld a,2
0145   6237 DD BE 0A           cp (ix+10)
0146   623A C2 94 62           jp nz,b00392
0147   623D CD DE 84           call cangl
0148   6240 C2 50 62           jp nz,b00268
0149   6243 DD 35 09           dec (ix+9)
0150   6246 DD 35 09           dec (ix+9)
0151   6249 AF                 xor a
0152   624A DD 77 07           ld (ix+7),a
0153   624D C3 55 62           jp b00277
0154   6250 3E 03       b00268 ld a,3
0155   6252 DD 77 0A           ld (ix+10),a
0156   6255 AF          b00277 xor a
0157   6256 DD BE 0B           cp (ix+11)
0158   6259 D2 66 62           jp nc,b00307
0159   625C DD 7E 0B           ld a,(ix+11)
0160   625F 3D                 dec a
0161   6260 DD 77 0B           ld (ix+11),a
0162   6263 C3 94 62           jp b00392
0163   6266 3E 04       b00307 ld a,4
0164   6268 57                 ld d,a
0165   6269 CD 21 86           call random
0166   626C 67                 ld h,a
0167   626D CD 4F 7F           call imul
0168   6270 7C                 ld a,h
0169   6271 32 53 77           ld (varrnd),a
0170   6274 AF                 xor a
0171   6275 21 53 77           ld hl,varrnd
0172   6278 BE                 cp (hl)
0173   6279 C2 94 62           jp nz,b00392
0174   627C CD 70 84           call laddu
0175   627F C2 89 62           jp nz,b00374
0176   6282 AF                 xor a
0177   6283 DD 77 0A           ld (ix+10),a
0178   6286 C3 94 62           jp b00392
0179   6289 CD 60 84    b00374 call laddd
0180   628C C2 94 62           jp nz,b00392
0181   628F 3E 01              ld a,1
0182   6291 DD 77 0A           ld (ix+10),a
0183   6294 3E 03       b00392 ld a,3
0184   6296 DD BE 0A           cp (ix+10)
0185   6299 C2 F4 62           jp nz,b00560
0186   629C CD E9 84           call cangr
0187   629F C2 B0 62           jp nz,b00436
0188   62A2 DD 34 09           inc (ix+9)
0189   62A5 DD 34 09           inc (ix+9)
0190   62A8 3E 01              ld a,1
0191   62AA DD 77 07           ld (ix+7),a
0192   62AD C3 B5 62           jp b00445
0193   62B0 3E 02       b00436 ld a,2
0194   62B2 DD 77 0A           ld (ix+10),a
0195   62B5 AF          b00445 xor a
0196   62B6 DD BE 0B           cp (ix+11)
0197   62B9 D2 C6 62           jp nc,b00475
0198   62BC DD 7E 0B           ld a,(ix+11)
0199   62BF 3D                 dec a
0200   62C0 DD 77 0B           ld (ix+11),a
0201   62C3 C3 F4 62           jp b00560
0202   62C6 3E 04       b00475 ld a,4
0203   62C8 57                 ld d,a
0204   62C9 CD 21 86           call random
0205   62CC 67                 ld h,a
0206   62CD CD 4F 7F           call imul
0207   62D0 7C                 ld a,h
0208   62D1 32 53 77           ld (varrnd),a
0209   62D4 AF                 xor a
0210   62D5 21 53 77           ld hl,varrnd
0211   62D8 BE                 cp (hl)
0212   62D9 C2 F4 62           jp nz,b00560
0213   62DC CD 70 84           call laddu
0214   62DF C2 E9 62           jp nz,b00542
0215   62E2 AF                 xor a
0216   62E3 DD 77 0A           ld (ix+10),a
0217   62E6 C3 F4 62           jp b00560
0218   62E9 CD 60 84    b00542 call laddd
0219   62EC C2 F4 62           jp nz,b00560
0220   62EF 3E 01              ld a,1
0221   62F1 DD 77 0A           ld (ix+10),a
0222   62F4 06 00       b00560 ld b,0
0223   62F6 CD 00 8A           call sktyp
0224   62F9 D2 00 63           jp nc,b00582
0225   62FC 21 59 77           ld hl,deadf
0226   62FF 74                 ld (hl),h
0227   6300 C9          b00582 ret
0228   6301             evnt02 equ $
0229   6301 AF                 xor a
0230   6302 DD BE 0B           cp (ix+11)
0231   6305 C2 22 63           jp nz,c00059
0232   6308 3E 42              ld a,66
0233   630A DD BE 0C           cp (ix+12)
0234   630D C2 18 63           jp nz,c00042
0235   6310 3E 01              ld a,1
0236   6312 DD 77 0B           ld (ix+11),a
0237   6315 C3 1F 63           jp c00055
0238   6318 DD 7E 0C    c00042 ld a,(ix+12)
0239   631B 3D                 dec a
0240   631C DD 77 0C           ld (ix+12),a
0241   631F C3 38 63    c00055 jp c00098
0242   6322 3E 46       c00059 ld a,70
0243   6324 DD BE 0C           cp (ix+12)
0244   6327 C2 31 63           jp nz,c00085
0245   632A AF                 xor a
0246   632B DD 77 0B           ld (ix+11),a
0247   632E C3 38 63           jp c00098
0248   6331 DD 7E 0C    c00085 ld a,(ix+12)
0249   6334 3C                 inc a
0250   6335 DD 77 0C           ld (ix+12),a
0251   6338 DD 7E 0C    c00098 ld a,(ix+12)
0252   633B E6 07              and 7
0253   633D 4F                 ld c,a
0254   633E CD 7E 7A           call cspr
0255   6341 06 00              ld b,0
0256   6343 CD 00 8A           call sktyp
0257   6346 D2 F4 63           jp nc,c00429
0258   6349 DD 36 05 FF        ld (ix+5),255
0259   634D 3E 14              ld a,20
0260   634F 32 81 5C           ld (loopa),a
0261   6352 CD 89 7C    c00141 call vapour
0262   6355 21 81 5C           ld hl,loopa
0263   6358 35                 dec (hl)
0264   6359 C2 52 63           jp nz,c00141
0265   635C 3E 07              ld a,7
0266   635E E6 07              and 7
0267   6360 4F                 ld c,a
0268   6361 CD 7E 7A           call cspr
0269   6364 21 64 00           ld hl,100
0270   6367 CD 74 82           call addsc
0271   636A 3A 37 77           ld a,(vara)
0272   636D 3D                 dec a
0273   636E 32 37 77           ld (vara),a
0274   6371 AF                 xor a
0275   6372 21 37 77           ld hl,vara
0276   6375 BE                 cp (hl)
0277   6376 C2 DC 63           jp nz,c00390
0278   6379 DD E5              push ix
0279   637B 06 32              ld b,50
0280   637D CD 3B 79           call delay
0281   6380 DD E1              pop ix
0282   6382 AF          c00228 xor a
0283   6383 21 4A 77           ld hl,vart
0284   6386 BE                 cp (hl)
0285   6387 D2 D8 63           jp nc,c00381
0286   638A 3A 4A 77           ld a,(vart)
0287   638D 3D                 dec a
0288   638E 32 4A 77           ld (vart),a
0289   6391 21 01 00           ld hl,1
0290   6394 CD 74 82           call addsc
0291   6397 21 0C 1A           ld hl,6668
0292   639A 22 50 77           ld (charx),hl
0293   639D 3A 4A 77           ld a,(vart)
0294   63A0 57                 ld d,a
0295   63A1 1E 3C              ld e,60
0296   63A3 CD 64 7F           call idiv
0297   63A6 F5                 push af
0298   63A7 7A                 ld a,d
0299   63A8 CD 5C 8A           call disply
0300   63AB 21 51 77           ld hl,chary
0301   63AE 34                 inc (hl)
0302   63AF F1                 pop af
0303   63B0 01 6D 8A           ld bc,displ0
0304   63B3 CD 31 7F           call num2dd
0305   63B6 CD 62 8A           call displ1
0306   63B9 21 03 19           ld hl,6403
0307   63BC 22 50 77           ld (charx),hl
0308   63BF 21 1C 82           ld hl,score
0309   63C2 06 06              ld b,6
0310   63C4 CD 36 82           call dscor
0311   63C7 3E 32              ld a,50
0312   63C9 32 E6 79           ld (sndtyp),a
0313   63CC DD E5              push ix
0314   63CE 06 02              ld b,2
0315   63D0 CD 3B 79           call delay
0316   63D3 DD E1              pop ix
0317   63D5 C3 82 63           jp c00228
0318   63D8 21 57 77    c00381 ld hl,nexlev
0319   63DB 74                 ld (hl),h
0320   63DC 21 43 8E    c00390 ld hl,fx1
0321   63DF 11 29 00           ld de,41
0322   63E2 19                 add hl,de
0323   63E3 CD 72 7F           call isnd
0324   63E6 21 03 19           ld hl,6403
0325   63E9 22 50 77           ld (charx),hl
0326   63EC 21 1C 82           ld hl,score
0327   63EF 06 06              ld b,6
0328   63F1 CD 36 82           call dscor
0329   63F4 C9          c00429 ret
0330   63F5             evnt03 equ $
0331   63F5 C9                 ret
0332   63F6             evnt04 equ $
0333   63F6 C9                 ret
0334   63F7             evnt05 equ $
0335   63F7 C9                 ret
0336   63F8             evnt06 equ $
0337   63F8 C9                 ret
0338   63F9             evnt07 equ $
0339   63F9 C9                 ret
0340   63FA             evnt08 equ $
0341   63FA C9                 ret
0342   63FB             evnt09 equ $
0343   63FB 3E 02              ld a,2
0344   63FD DD BE 05           cp (ix+5)
0345   6400 C2 13 64           jp nz,j00045
0346   6403 3A 37 77           ld a,(vara)
0347   6406 3C                 inc a
0348   6407 32 37 77           ld (vara),a
0349   640A AF                 xor a
0350   640B DD 77 0B           ld (ix+11),a
0351   640E 3E 45              ld a,69
0352   6410 DD 77 0C           ld (ix+12),a
0353   6413 C9          j00045 ret
0354   6414             evnt10 equ $
0355   6414 3A 49 77           ld a,(vars)
0356   6417 3C                 inc a
0357   6418 32 49 77           ld (vars),a
0358   641B 3E 19              ld a,25
0359   641D 21 49 77           ld hl,vars
0360   6420 BE                 cp (hl)
0361   6421 D2 5E 64           jp nc,k00143
0362   6424 0E 19              ld c,25
0363   6426 3A 49 77           ld a,(vars)
0364   6429 91                 sub c
0365   642A 32 49 77           ld (vars),a
0366   642D AF                 xor a
0367   642E 21 4A 77           ld hl,vart
0368   6431 BE                 cp (hl)
0369   6432 D2 3C 64           jp nc,k00078
0370   6435 3A 4A 77           ld a,(vart)
0371   6438 3D                 dec a
0372   6439 32 4A 77           ld (vart),a
0373   643C 21 0C 1A    k00078 ld hl,6668
0374   643F 22 50 77           ld (charx),hl
0375   6442 3A 4A 77           ld a,(vart)
0376   6445 57                 ld d,a
0377   6446 1E 3C              ld e,60
0378   6448 CD 64 7F           call idiv
0379   644B F5                 push af
0380   644C 7A                 ld a,d
0381   644D CD 5C 8A           call disply
0382   6450 21 51 77           ld hl,chary
0383   6453 34                 inc (hl)
0384   6454 F1                 pop af
0385   6455 01 6D 8A           ld bc,displ0
0386   6458 CD 31 7F           call num2dd
0387   645B CD 62 8A           call displ1
0388   645E C9          k00143 ret
0389   645F             evnt11 equ $
0390   645F C9                 ret
0391   6460             evnt12 equ $
0392   6460 3E 0F              ld a,15
0393   6462 E6 07              and 7
0394   6464 4F                 ld c,a
0395   6465 21 8D 5C           ld hl,23693
0396   6468 7E                 ld a,(hl)
0397   6469 E6 F8              and 248
0398   646B B1                 or c
0399   646C 77                 ld (hl),a
0400   646D AF                 xor a
0401   646E 17                 rla
0402   646F 17                 rla
0403   6470 17                 rla
0404   6471 E6 38              and 56
0405   6473 4F                 ld c,a
0406   6474 21 8D 5C           ld hl,23693
0407   6477 7E                 ld a,(hl)
0408   6478 E6 C7              and 199
0409   647A B1                 or c
0410   647B 77                 ld (hl),a
0411   647C CD 17 7A           call cls
0412   647F 21 04 09           ld hl,2308
0413   6482 22 50 77           ld (charx),hl
0414   6485 3E 63              ld a,99
0415   6487 32 4F 77           ld (contrl),a
0416   648A 3E 63       m00095 ld a,99
0417   648C 21 4F 77           ld hl,contrl
0418   648F BE                 cp (hl)
0419   6490 28 03              jr z,$+5
0420   6492 D2 09 65           jp nc,m00312
0421   6495 CD 17 7A           call cls
0422   6498 21 05 09           ld hl,2309
0423   649B 22 50 77           ld (charx),hl
0424   649E 3E 01              ld a,1
0425   64A0 32 00 87           ld (prtmod),a
0426   64A3 AF                 xor a
0427   64A4 CD BA 86           call dmsg
0428   64A7 AF                 xor a
0429   64A8 32 00 87           ld (prtmod),a
0430   64AB 21 09 0A           ld hl,2569
0431   64AE 22 50 77           ld (charx),hl
0432   64B1 3E 01              ld a,1
0433   64B3 CD BA 86           call dmsg
0434   64B6 21 0B 0A           ld hl,2571
0435   64B9 22 50 77           ld (charx),hl
0436   64BC 3E 02              ld a,2
0437   64BE CD BA 86           call dmsg
0438   64C1 21 0D 0A           ld hl,2573
0439   64C4 22 50 77           ld (charx),hl
0440   64C7 3E 03              ld a,3
0441   64C9 CD BA 86           call dmsg
0442   64CC 3E 63              ld a,99
0443   64CE 32 4F 77           ld (contrl),a
0444   64D1 3E 63       m00216 ld a,99
0445   64D3 21 4F 77           ld hl,contrl
0446   64D6 BE                 cp (hl)
0447   64D7 C2 06 65           jp nz,m00307
0448   64DA 3A B9 76           ld a,(keys+7)
0449   64DD CD 33 86           call ktest
0450   64E0 DA E7 64           jp c,m00257
0451   64E3 AF                 xor a
0452   64E4 32 4F 77           ld (contrl),a
0453   64E7 3A BA 76    m00257 ld a,(keys+8)
0454   64EA CD 33 86           call ktest
0455   64ED DA F5 64           jp c,m00280
0456   64F0 3E 01              ld a,1
0457   64F2 32 4F 77           ld (contrl),a
0458   64F5 3A BB 76    m00280 ld a,(keys+9)
0459   64F8 CD 33 86           call ktest
0460   64FB DA 03 65           jp c,m00303
0461   64FE 3E 02              ld a,2
0462   6500 32 4F 77           ld (contrl),a
0463   6503 C3 D1 64    m00303 jp m00216
0464   6506 C3 8A 64    m00307 jp m00095
0465   6509 CD 17 7A    m00312 call cls
0466   650C C9                 ret
0467   650D             evnt13 equ $
0468   650D 3E 03              ld a,3
0469   650F 32 36 77           ld (numlif),a
0470   6512 AF                 xor a
0471   6513 32 35 77           ld (scno),a
0472   6516 CD B4 8A           call nwscr
0473   6519 3E 07              ld a,7
0474   651B E6 07              and 7
0475   651D 4F                 ld c,a
0476   651E 21 8D 5C           ld hl,23693
0477   6521 7E                 ld a,(hl)
0478   6522 E6 F8              and 248
0479   6524 B1                 or c
0480   6525 77                 ld (hl),a
0481   6526 3E 02              ld a,2
0482   6528 17                 rla
0483   6529 17                 rla
0484   652A 17                 rla
0485   652B E6 38              and 56
0486   652D 4F                 ld c,a
0487   652E 21 8D 5C           ld hl,23693
0488   6531 7E                 ld a,(hl)
0489   6532 E6 C7              and 199
0490   6534 B1                 or c
0491   6535 77                 ld (hl),a
0492   6536 3E 02              ld a,2
0493   6538 CD 9B 22           call 8859
0494   653B CD 17 7A           call cls
0495   653E 21 02 19           ld hl,6402
0496   6541 22 50 77           ld (charx),hl
0497   6544 3E 04              ld a,4
0498   6546 CD BA 86           call dmsg
0499   6549 21 05 19           ld hl,6405
0500   654C 22 50 77           ld (charx),hl
0501   654F 3E 05              ld a,5
0502   6551 CD BA 86           call dmsg
0503   6554 21 08 1A           ld hl,6664
0504   6557 22 50 77           ld (charx),hl
0505   655A 3E 06              ld a,6
0506   655C CD BA 86           call dmsg
0507   655F 21 0B 1A           ld hl,6667
0508   6562 22 50 77           ld (charx),hl
0509   6565 3E 07              ld a,7
0510   6567 CD BA 86           call dmsg
0511   656A 21 0C 1B           ld hl,6924
0512   656D 22 50 77           ld (charx),hl
0513   6570 3E 08              ld a,8
0514   6572 CD BA 86           call dmsg
0515   6575 21 0E 19           ld hl,6414
0516   6578 22 50 77           ld (charx),hl
0517   657B 3E 09              ld a,9
0518   657D CD BA 86           call dmsg
0519   6580 AF                 xor a
0520   6581 E6 07              and 7
0521   6583 4F                 ld c,a
0522   6584 21 8D 5C           ld hl,23693
0523   6587 7E                 ld a,(hl)
0524   6588 E6 F8              and 248
0525   658A B1                 or c
0526   658B 77                 ld (hl),a
0527   658C 3E 06              ld a,6
0528   658E 17                 rla
0529   658F 17                 rla
0530   6590 17                 rla
0531   6591 E6 38              and 56
0532   6593 4F                 ld c,a
0533   6594 21 8D 5C           ld hl,23693
0534   6597 7E                 ld a,(hl)
0535   6598 E6 C7              and 199
0536   659A B1                 or c
0537   659B 77                 ld (hl),a
0538   659C 21 03 19           ld hl,6403
0539   659F 22 50 77           ld (charx),hl
0540   65A2 21 1C 82           ld hl,score
0541   65A5 06 06              ld b,6
0542   65A7 CD 36 82           call dscor
0543   65AA 21 09 19           ld hl,6409
0544   65AD 22 50 77           ld (charx),hl
0545   65B0 21 22 82           ld hl,hiscor
0546   65B3 06 06              ld b,6
0547   65B5 CD 36 82           call dscor
0548   65B8 C9                 ret
0549   65B9             evnt14 equ $
0550   65B9 21 06 1B           ld hl,6918
0551   65BC 22 50 77           ld (charx),hl
0552   65BF 3A 36 77           ld a,(numlif)
0553   65C2 CD 5C 8A           call disply
0554   65C5 3A 35 77           ld a,(scno)
0555   65C8 32 49 77           ld (vars),a
0556   65CB 3A 49 77           ld a,(vars)
0557   65CE 3C                 inc a
0558   65CF 32 49 77           ld (vars),a
0559   65D2 21 0F 1A           ld hl,6671
0560   65D5 22 50 77           ld (charx),hl
0561   65D8 3A 49 77           ld a,(vars)
0562   65DB 01 6D 8A           ld bc,displ0
0563   65DE CD 40 7F           call num2td
0564   65E1 CD 62 8A           call displ1
0565   65E4 AF                 xor a
0566   65E5 32 37 77           ld (vara),a
0567   65E8 3E 3C              ld a,60
0568   65EA 32 4A 77           ld (vart),a
0569   65ED AF                 xor a
0570   65EE 32 49 77           ld (vars),a
0571   65F1 AF                 xor a
0572   65F2 32 41 77           ld (vark),a
0573   65F5 21 0C 1A           ld hl,6668
0574   65F8 22 50 77           ld (charx),hl
0575   65FB 3A 4A 77           ld a,(vart)
0576   65FE 57                 ld d,a
0577   65FF 1E 3C              ld e,60
0578   6601 CD 64 7F           call idiv
0579   6604 F5                 push af
0580   6605 7A                 ld a,d
0581   6606 CD 5C 8A           call disply
0582   6609 21 51 77           ld hl,chary
0583   660C 34                 inc (hl)
0584   660D F1                 pop af
0585   660E 01 6D 8A           ld bc,displ0
0586   6611 CD 31 7F           call num2dd
0587   6614 CD 62 8A           call displ1
0588   6617 C9                 ret
0589   6618             evnt15 equ $
0590   6618 AF                 xor a
0591   6619 DD BE 05           cp (ix+5)
0592   661C C2 23 66           jp nz,p00024
0593   661F 21 59 77           ld hl,deadf
0594   6622 74                 ld (hl),h
0595   6623 C9          p00024 ret
0596   6624             evnt16 equ $
0597   6624 21 43 8E           ld hl,fx1
0598   6627 11 00 00           ld de,0
0599   662A 19                 add hl,de
0600   662B CD 72 7F           call isnd
0601   662E 3A 36 77           ld a,(numlif)
0602   6631 3D                 dec a
0603   6632 32 36 77           ld (numlif),a
0604   6635 C9                 ret
0605   6636             evnt17 equ $
0606   6636 DD E5              push ix
0607   6638 06 32              ld b,50
0608   663A CD 3B 79           call delay
0609   663D DD E1              pop ix
0610   663F C9                 ret
0611   6640             evnt18 equ $
0612   6640 DD E5              push ix
0613   6642 06 32              ld b,50
0614   6644 CD 3B 79           call delay
0615   6647 DD E1              pop ix
0616   6649 C9                 ret
0617   664A             evnt19 equ $
0618   664A 3E 05              ld a,5
0619   664C E6 07              and 7
0620   664E 4F                 ld c,a
0621   664F 21 8D 5C           ld hl,23693
0622   6652 7E                 ld a,(hl)
0623   6653 E6 F8              and 248
0624   6655 B1                 or c
0625   6656 77                 ld (hl),a
0626   6657 AF                 xor a
0627   6658 17                 rla
0628   6659 17                 rla
0629   665A 17                 rla
0630   665B E6 38              and 56
0631   665D 4F                 ld c,a
0632   665E 21 8D 5C           ld hl,23693
0633   6661 7E                 ld a,(hl)
0634   6662 E6 C7              and 199
0635   6664 B1                 or c
0636   6665 77                 ld (hl),a
0637   6666 CD 9E 8C           call clw
0638   6669 CD A1 7D           call inishr
0639   666C 3E 01              ld a,1
0640   666E 32 00 87           ld (prtmod),a
0641   6671 21 04 05           ld hl,1284
0642   6674 22 50 77           ld (charx),hl
0643   6677 3E 0A              ld a,10
0644   6679 CD BA 86           call dmsg
0645   667C AF                 xor a
0646   667D 32 00 87           ld (prtmod),a
0647   6680 DD E5              push ix
0648   6682 06 64              ld b,100
0649   6684 CD 3B 79           call delay
0650   6687 DD E1              pop ix
0651   6689 C9                 ret
0652   668A             evnt20 equ $
0653   668A 3E 01              ld a,1
0654   668C 32 41 77           ld (vark),a
0655   668F C9                 ret
0656   6690 C9          ptcusr ret
0657   6691             msgdat equ $
0658   6691                    defb 'DIAMOND GEEZE',210
0658   6691 4449414D4F4E44204745455A45D2
0659   669F                    defb '1. KEYBOAR',196
0659   669F 312E204B4559424F4152C4
0660   66AA                    defb '2. KEMPSTO',206
0660   66AA 322E204B454D5053544FCE
0661   66B5                    defb '3. SINCLAI',210
0661   66B5 332E2053494E434C4149D2
0662   66C0 53434F52C5         defb 'SCOR',197
0663   66C5 4C495645D3         defb 'LIVE',211
0664   66CA 48 49 47 C8        defb 'HIG',200
0665   66CE 54 49 4D C5        defb 'TIM',197
0666   66D2 BA                 defb 186
0667   66D3 4C455645CC         defb 'LEVE',204
0668   66D8                    defb 'NEW HIGH SCOR',197
0668   66D8 4E455720484947482053434F52C5
0669   66E6 0B          nummsg defb 11
0670   66E7             scdat  equ $
0671   66E7                    defw 211,206,259,246,289,281
0671   66E7 D300CE000301F60021011901
0672   66F3                    defb 1,255,0,20,1,1,255,0,20,1,1,255,0,20,1,1,255,0,20,1,1,255,0,20,255,1,8,2,2,255,1,10,2,2
0672   66F3 01FF00140101FF00140101FF00140101FF00140101FF0014FF01080202FF010A
0672   6713 0202
0673   6715                    defb 1,1,255,0,6,2,2,255,0,10,2,2,1,1,255,0,6,2,2,255,0,10,2,2,1,1,2,2,255,1,11,2,2
0673   6715 0101FF00060202FF000A02020101FF00060202FF000A020201010202FF010B02
0673   6735 02
0674   6736                    defb 255,1,7,2,2,255,0,11,2,2,255,0,5,1,1,2,2,255,0,11,2,2,255,0,5,255,1,4,2,2,255,1,13
0674   6736 FF01070202FF000B0202FF000501010202FF000B0202FF0005FF01040202FF01
0674   6756 0D
0675   6757                    defb 2,2,1,1,1,0,0,2,2,255,0,13,2,2,0,1,1,0,0,2,2,255,0,13,2,2,0,255,1,6,2,2,255,1,6
0675   6757 020201010100000202FF000D020200010100000202FF000D020200FF01060202
0675   6777 FF0106
0676   677A                    defb 2,2,255,1,8,255,0,4,2,2,255,0,6,2,2,255,0,6,1,1,255,0,4,2,2,255,0,6,2,2,255,0,6
0676   677A 0202FF0108FF00040202FF00060202FF00060101FF00040202FF00060202FF00
0676   679A 06
0677   679B                    defb 255,1,10,2,2,255,1,7,2,2,1,1,1,255,0,8,2,2,255,0,7,2,2,0,1,1,255,0,8,2,2,255,0,7
0677   679B FF010A0202FF01070202010101FF00080202FF00070202000101FF00080202FF
0677   67BB 0007
0678   67BD                    defb 2,2,0,255,1,23,255,0,22
0678   67BD 020200FF0117FF0016
0679   67C6                    defb 1,255,0,20,1,1,255,0,20,1,1,255,0,20,1,1,255,0,20,1,1,255,0,20,1,1,2,2,255,1,16,2,2
0679   67C6 01FF00140101FF00140101FF00140101FF00140101FF001401010202FF011002
0679   67E6 02
0680   67E7                    defb 1,1,2,2,255,0,16,2,2,1,1,2,2,255,0,16,2,2,255,1,11,2,2,255,1,11,255,0,9,2,2,1,1,1
0680   67E7 01010202FF0010020201010202FF00100202FF010B0202FF010BFF0009020201
0680   6807 0101
0681   6809                    defb 255,0,6,1,1,255,0,9,2,2,1,1,1,255,0,6,255,1,9,2,2,255,1,7,2,2,255,1,4,255,0,7,2,2
0681   6809 FF00060101FF00090202010101FF0006FF01090202FF01070202FF0104FF0007
0681   6829 0202
0682   682B                    defb 255,0,7,2,2,0,0,1,1,255,0,7,2,2,255,0,7,2,2,0,0,255,1,5,2,2,255,1,7,2,2,255,1,8
0682   682B FF0007020200000101FF00070202FF000702020000FF01050202FF01070202FF
0682   684B 0108
0683   684D                    defb 0,0,0,2,2,255,0,7,2,2,255,0,6,1,1,0,0,0,2,2,255,0,7,2,2,255,0,6,255,1,8,2,2
0683   684D 0000000202FF00070202FF000601010000000202FF00070202FF0006FF010802
0683   686D 02
0684   686E                    defb 255,1,9,2,2,1,1,1,255,0,6,2,2,255,0,9,2,2,0,1,1,255,0,6,2,2,255,0,9,2,2,0,255,1,23
0684   686E FF01090202010101FF00060202FF00090202000101FF00060202FF0009020200
0684   688E FF0117
0685   6891 FF 00 16           defb 255,0,22
0686   6894                    defb 255,1,4,255,0,10,1,255,0,6,255,1,5,255,0,10,1,255,0,6,255,1,5,255,0,10,1,255,0,6,255,1,9
0686   6894 FF0104FF000A01FF0006FF0105FF000A01FF0006FF0105FF000A01FF0006FF01
0686   68B4 09
0687   68B5                    defb 2,2,255,1,9,2,2,1,1,255,0,7,2,2,255,0,8,1,2,2,1,1,255,0,7,2,2,255,0,8,1,2,2
0687   68B5 0202FF010902020101FF00070202FF00080102020101FF00070202FF00080102
0687   68D5 02
0688   68D6                    defb 255,1,4,2,2,255,1,8,2,2,255,1,4,2,2,1,1,0,0,2,2,255,0,8,2,2,255,0,4,2,2,1,1
0688   68D6 FF01040202FF01080202FF01040202010100000202FF00080202FF0004020201
0688   68F6 01
0689   68F7                    defb 0,0,2,2,255,0,8,2,2,255,0,4,2,2,255,1,8,2,2,255,1,14,255,0,6,2,2,255,0,12,1,1,255,0,6
0689   68F7 00000202FF00080202FF00040202FF01080202FF010EFF00060202FF000C0101
0689   6917 FF0006
0690   691A                    defb 2,2,255,0,12,255,1,5,2,2,255,1,9,2,2,255,1,6,0,0,0,2,2,255,0,9,2,2,255,0,4,1,1
0690   691A 0202FF000CFF01050202FF01090202FF01060000000202FF00090202FF000401
0690   693A 01
0691   693B                    defb 0,0,0,2,2,255,0,9,2,2,255,0,4,1,1,2,2,255,1,16,2,2,1,1,2,2,255,0,16,2,2,1,1
0691   693B 0000000202FF00090202FF000401010202FF0110020201010202FF0010020201
0691   695B 01
0692   695C                    defb 2,2,255,0,16,2,2,255,1,6,2,2,255,1,8,2,2,255,1,6,255,0,4,2,2,255,0,4,1,0,0,0,2,2
0692   695C 0202FF00100202FF01060202FF01080202FF0106FF00040202FF000401000000
0692   697C 0202
0693   697E                    defb 255,0,4,1,1,255,0,4,2,2,255,0,4,1,0,0,0,2,2,255,0,4,255,1,23
0693   697E FF00040101FF00040202FF0004010000000202FF0004FF0117
0694   6997                    defb 1,255,0,20,1,1,255,0,20,1,1,255,0,20,255,1,12,2,2,1,2,2,255,1,7,255,0,10,2,2,1,2,2
0694   6997 01FF00140101FF00140101FF0014FF010C0202010202FF0107FF000A02020102
0694   69B7 02
0695   69B8                    defb 255,0,5,1,1,255,0,10,2,2,1,2,2,255,0,5,255,1,6,2,2,255,1,10,2,2,255,1,4,255,0,4,2,2
0695   69B8 FF00050101FF000A0202010202FF0005FF01060202FF010A0202FF0104FF0004
0695   69D8 0202
0696   69DA                    defb 255,0,10,2,2,0,0,1,1,255,0,4,2,2,255,0,10,2,2,0,0,255,1,15,2,2,255,1,7,255,0,6,1
0696   69DA FF000A020200000101FF00040202FF000A02020000FF010F0202FF0107FF0006
0696   69FA 01
0697   69FB                    defb 255,0,6,2,2,255,0,5,1,1,255,0,6,1,255,0,6,2,2,255,0,5,255,1,6,2,2,1,1,2,2,255,1,8
0697   69FB FF00060202FF00050101FF000601FF00060202FF0005FF0106020201010202FF
0697   6A1B 0108
0698   6A1D                    defb 2,2,1,1,255,0,4,2,2,0,0,2,2,255,0,8,2,2,1,1,255,0,4,2,2,0,0,2,2,255,0,8,2,2
0698   6A1D 02020101FF0004020200000202FF000802020101FF0004020200000202FF0008
0698   6A3D 0202
0699   6A3F                    defb 1,1,2,2,255,1,11,2,2,255,1,7,2,2,255,0,11,2,2,1,255,0,4,1,1,2,2,255,0,11,2,2,1
0699   6A3F 01010202FF010B0202FF01070202FF000B020201FF000401010202FF000B0202
0699   6A5F 01
0700   6A60                    defb 255,0,4,255,1,5,2,2,255,1,11,2,2,255,1,4,0,0,0,2,2,255,0,11,2,2,0,0,1,1,0,0,0
0700   6A60 FF0004FF01050202FF010B0202FF01040000000202FF000B0202000001010000
0700   6A80 00
0701   6A81                    defb 2,2,255,0,11,2,2,0,0,255,1,23
0701   6A81 0202FF000B02020000FF0117
0702   6A8D                    defb 1,255,0,5,255,1,17,255,0,4,4,1,0,0,0,3,255,0,10,1,1,255,0,5,1,0,0,0,3,255,0,10,1,1
0702   6A8D 01FF0005FF0111FF0004040100000003FF000A0101FF00050100000003FF000A
0702   6AAD 0101
0703   6AAF                    defb 2,2,255,1,8,2,2,255,1,10,2,2,1,255,0,7,2,2,255,0,8,1,1,2,2,1,255,0,7,2,2,255,0,8
0703   6AAF 0202FF01080202FF010A020201FF00070202FF00080101020201FF00070202FF
0703   6ACF 0008
0704   6AD1                    defb 1,1,2,2,255,1,5,2,2,255,1,4,2,2,1,1,1,2,2,1,1,2,2,255,0,5,2,2,255,0,4,2,2
0704   6AD1 01010202FF01050202FF01040202010101020201010202FF00050202FF000402
0704   6AF1 02
0705   6AF2                    defb 0,0,0,2,2,1,1,2,2,255,0,5,2,2,255,0,4,2,2,0,0,0,2,2,255,1,6,2,2,255,1,4,2,2
0705   6AF2 000000020201010202FF00050202FF000402020000000202FF01060202FF0104
0705   6B12 0202
0706   6B14                    defb 255,1,11,0,0,0,2,2,255,0,4,2,2,255,0,8,1,1,1,0,0,0,2,2,255,0,4,2,2,255,0,8,1,1,1
0706   6B14 FF010B0000000202FF00040202FF00080101010000000202FF00040202FF0008
0706   6B34 010101
0707   6B37                    defb 2,2,255,1,13,2,2,255,1,5,2,2,255,0,13,2,2,0,0,1,1,1,2,2,255,0,13,2,2,0,0,255,1,6
0707   6B37 0202FF010D0202FF01050202FF000D020200000101010202FF000D02020000FF
0707   6B57 0106
0708   6B59                    defb 2,2,255,1,6,2,2,255,1,8,255,0,4,2,2,255,0,5,1,2,2,255,0,6,1,1,255,0,4,2,2,255,0,5
0708   6B59 0202FF01060202FF0108FF00040202FF0005010202FF00060101FF00040202FF
0708   6B79 0005
0709   6B7B                    defb 1,2,2,255,0,6,1,1,2,2,255,1,7,2,2,255,1,7,2,2,1,1,2,2,255,0,7,2,2,255,0,7,2,2
0709   6B7B 010202FF000601010202FF01070202FF0107020201010202FF00070202FF0007
0709   6B9B 0202
0710   6B9D                    defb 1,1,2,2,255,0,7,2,2,255,0,7,2,2,255,1,23
0710   6B9D 01010202FF00070202FF00070202FF0117
0711   6BAE                    defb 1,4,0,0,0,1,255,0,15,1,1,255,0,20,255,1,4,2,2,255,0,16,255,1,8,2,2,255,1,8,2,2,255,1,4
0711   6BAE 010400000001FF000F0101FF0014FF01040202FF0010FF01080202FF01080202
0711   6BCE FF0104
0712   6BD1                    defb 255,0,6,2,2,255,0,8,2,2,0,0,1,1,255,0,6,2,2,255,0,8,2,2,0,0,255,1,4,2,2,255,1,6
0712   6BD1 FF00060202FF0008020200000101FF00060202FF000802020000FF01040202FF
0712   6BF1 0106
0713   6BF3                    defb 2,2,255,1,10,0,0,2,2,255,0,6,2,2,255,0,8,1,1,0,0,2,2,255,0,6,2,2,255,0,8,255,1,7
0713   6BF3 0202FF010A00000202FF00060202FF0008010100000202FF00060202FF0008FF
0713   6C13 0107
0714   6C15                    defb 2,2,255,1,11,2,2,1,1,255,0,5,2,2,255,0,4,3,255,0,6,2,2,1,1,255,0,5,2,2,255,0,4
0714   6C15 0202FF010B02020101FF00050202FF000403FF000602020101FF00050202FF00
0714   6C35 04
0715   6C36                    defb 3,255,0,6,2,2,1,1,2,2,255,1,7,2,2,1,2,2,255,1,8,2,2,255,0,7,2,2,1,2,2,255,0,6
0715   6C36 03FF0006020201010202FF01070202010202FF01080202FF00070202010202FF
0715   6C56 0006
0716   6C58                    defb 1,1,2,2,255,0,7,2,2,1,2,2,255,0,6,255,1,8,2,2,255,1,7,2,2,1,2,2,1,1,255,0,6
0716   6C58 01010202FF00070202010202FF0006FF01080202FF010702020102020101FF00
0716   6C78 06
0717   6C79                    defb 2,2,0,0,0,1,0,0,0,2,2,1,2,2,1,1,255,0,6,2,2,0,0,0,1,0,0,0,2,2,1,2,2
0717   6C79 02020000000100000002020102020101FF000602020000000100000002020102
0717   6C99 02
0718   6C9A                    defb 1,1,2,2,255,1,10,2,2,255,1,4,2,2,1,1,2,2,255,0,10,2,2,255,0,4,2,2,1,1,2,2,255,0,10
0718   6C9A 01010202FF010A0202FF0104020201010202FF000A0202FF0004020201010202
0718   6CBA FF000A
0719   6CBD                    defb 2,2,255,0,4,2,2,255,1,23
0719   6CBD 0202FF00040202FF0117
0720   6CC7 06          numsc  defb 6
0721   6CC8             chgfx  equ $
0722   6CC8                    defb 0,0,0,0,0,0,0,0
0722   6CC8 0000000000000000
0723   6CD0                    defb 254,254,254,0,239,239,239,0
0723   6CD0 FEFEFE00EFEFEF00
0724   6CD8                    defb 0,0,255,0,0,0,255,0
0724   6CD8 0000FF000000FF00
0725   6CE0                    defb 170,85,170,85,170,85,170,85
0725   6CE0 AA55AA55AA55AA55
0726   6CE8                    defb 6,9,9,22,32,64,224,64
0726   6CE8 060909162040E040
0727   6CF0             bcol   equ $
0728   6CF0 47                 defb 71
0729   6CF1 42                 defb 66
0730   6CF2 47                 defb 71
0731   6CF3 44                 defb 68
0732   6CF4 47                 defb 71
0733   6CF5             bprop  equ $
0734   6CF5 00                 defb 0
0735   6CF6 02                 defb 2
0736   6CF7 03                 defb 3
0737   6CF8 04                 defb 4
0738   6CF9 08                 defb 8
0739   6CFA             sprgfx equ $
0740   6CFA                    defb 67,128,55,197,103,226,39,229,19,228,15,248,1,240,1,240,3,240,3,224,7,224,15,224,23,208,19,144,56,24,120,60
0740   6CFA 438037C567E227E513E40FF801F001F003F003E007E00FE017D013903818783C
0741   6D1A                    defb 16,224,77,241,153,248,73,249,4,249,3,254,0,124,0,124,0,252,0,248,1,248,3,248,5,244,4,228,14,6,30,15
0741   6D1A 10E04DF199F849F904F903FE007C007C00FC00F801F803F805F404E40E061E0F
0742   6D3A                    defb 4,56,83,124,38,126,82,126,65,62,128,255,0,31,0,31,0,63,0,62,0,126,0,254,1,125,1,57,131,129,199,131
0742   6D3A 0438537C267E527E413E80FF001F001F003F003E007E00FE017D01398381C783
0743   6D5A                    defb 1,14,20,223,137,159,148,159,144,79,224,63,192,7,192,7,192,15,128,15,128,31,128,63,64,95,64,78,96,224,241,224
0743   6D5A 010E14DF899F949F904FE03FC007C007C00F800F801F803F405F404E60E0F1E0
0744   6D7A                    defb 0,0,3,128,7,192,87,229,39,226,83,237,15,241,1,240,1,240,3,240,3,224,7,224,15,240,23,200,227,134,224,15
0744   6D7A 0000038007C057E527E253ED0FF101F001F003F003E007E00FF017C8E386E00F
0745   6D9A                    defb 0,0,0,224,1,240,85,249,137,248,84,251,67,252,0,124,0,124,0,252,0,248,1,248,3,252,5,242,184,225,248,3
0745   6D9A 000000E001F055F989F854FB43FC007C007C00FC00F801F803FC05F2B8E1F803
0746   6DBA                    defb 0,0,0,56,0,124,85,126,34,126,213,62,16,255,0,31,0,31,0,63,0,62,0,126,0,255,129,124,110,56,254,0
0746   6DBA 00000038007C557E227ED53E10FF001F001F003F003E007E00FF817C6E38FE00
0747   6DDA                    defb 0,0,0,14,0,31,149,95,136,159,181,79,196,63,192,7,192,7,192,15,128,15,128,31,192,63,32,95,27,142,63,128
0747   6DDA 0000000E001F955F889FB54FC43FC007C007C00F800F801FC03F205F1B8E3F80
0748   6DFA                    defb 3,128,7,192,7,224,7,224,67,224,35,241,253,250,33,247,3,242,3,225,7,224,15,224,23,208,19,144,56,24,120,60
0748   6DFA 038007C007E007E043E023F1FDFA21F703F203E107E00FE017D013903818783C
0749   6E1A                    defb 0,224,1,240,1,248,1,248,16,248,72,252,191,126,200,125,128,252,64,248,1,248,3,248,5,244,4,228,14,6,30,15
0749   6E1A 00E001F001F801F810F848FCBF7EC87D80FC40F801F803F805F404E40E061E0F
0750   6E3A                    defb 0,56,0,124,0,126,0,126,4,62,18,63,175,223,114,31,32,63,16,62,0,126,0,254,1,125,1,57,131,129,199,131
0750   6E3A 0038007C007E007E043E123FAFDF721F203F103E007E00FE017D01398381C783
0751   6E5A                    defb 0,14,0,31,128,31,128,31,129,15,196,143,235,247,220,135,200,15,132,15,128,31,128,63,64,95,64,78,96,224,241,224
0751   6E5A 000E001F801F801F810FC48FEBF7DC87C80F840F801F803F405F404E60E0F1E0
0752   6E7A                    defb 3,128,7,192,7,224,87,229,35,226,83,253,13,241,1,240,3,240,3,224,7,224,7,224,7,224,3,160,15,112,15,112
0752   6E7A 038007C007E057E523E253FD0DF101F003F003E007E007E007E003A00F700F70
0753   6E9A                    defb 0,224,1,240,1,248,85,249,136,248,84,255,67,124,0,124,0,252,0,248,1,248,1,248,1,248,0,232,3,220,3,220
0753   6E9A 00E001F001F855F988F854FF437C007C00FC00F801F801F801F800E803DC03DC
0754   6EBA                    defb 0,56,0,124,0,126,85,126,34,62,213,63,16,223,0,31,0,63,0,62,0,126,0,126,0,126,0,58,0,247,0,247
0754   6EBA 0038007C007E557E223ED53F10DF001F003F003E007E007E007E003A00F700F7
0755   6EDA                    defb 0,14,0,31,128,31,149,95,136,143,245,79,196,55,192,7,192,15,128,15,128,31,128,31,128,31,128,14,192,61,192,61
0755   6EDA 000E001F801F955F888FF54FC437C007C00F800F801F801F801F800EC03DC03D
0756   6EFA                    defb 1,192,195,224,199,224,39,224,47,192,31,243,15,143,15,128,15,192,7,216,7,246,7,247,59,224,33,192,224,0,224,0
0756   6EFA 01C0C3E0C7E027E02FC01FF30F8F0F800FC007D807F607F73BE021C0E000E000
0757   6F1A                    defb 0,112,48,248,49,248,9,248,11,240,199,252,195,227,3,224,3,240,1,246,129,253,193,253,14,248,8,112,56,0,56,0
0757   6F1A 007030F831F809F80BF0C7FCC3E303E003F001F681FDC1FD0EF8087038003800
0758   6F3A                    defb 0,28,12,62,12,126,2,126,2,252,49,255,240,248,0,248,0,252,128,125,96,127,112,127,3,190,2,28,14,0,14,0
0758   6F3A 001C0C3E0C7E027E02FC31FFF0F800F800FC807D607F707F03BE021C0E000E00
0759   6F5A                    defb 0,7,131,15,131,31,128,159,0,191,204,127,60,62,0,62,0,63,96,31,216,31,220,31,128,239,0,135,3,128,3,128
0759   6F5A 0007830F831F809F00BFCC7F3C3E003E003F601FD81FDC1F80EF008703800380
0760   6F7A                    defb 1,192,3,224,7,224,199,227,207,207,63,240,15,128,15,128,15,192,7,192,55,232,47,244,227,231,225,199,0,0,0,0
0760   6F7A 01C003E007E0C7E3CFCF3FF00F800F800FC007C037E82FF4E3E7E1C700000000
0761   6F9A                    defb 0,112,0,248,1,248,241,248,243,243,15,252,3,224,3,224,3,240,1,240,13,250,11,253,248,249,248,113,0,0,0,0
0761   6F9A 007000F801F8F1F8F3F30FFC03E003E003F001F00DFA0BFDF8F9F87100000000
0762   6FBA                    defb 0,28,0,62,0,126,60,126,252,252,3,255,0,248,0,248,0,252,0,124,131,126,66,255,126,62,126,28,0,0,0,0
0762   6FBA 001C003E007E3C7EFCFC03FF00F800F800FC007C837E42FF7E3E7E1C00000000
0763   6FDA                    defb 0,7,128,15,128,31,143,31,63,63,192,255,0,62,0,62,0,63,0,31,160,223,208,191,159,143,31,135,0,0,0,0
0763   6FDA 0007800F801F8F1F3F3FC0FF003E003E003F001FA0DFD0BF9F8F1F8700000000
0764   6FFA                    defb 1,192,3,227,7,227,7,228,15,200,207,240,223,128,47,128,15,192,63,192,231,224,231,240,3,232,1,196,0,7,0,7
0764   6FFA 01C003E307E307E40FC8CFF0DF802F800FC03FC0E7E0E7F003E801C400070007
0765   701A                    defb 0,112,192,248,193,248,1,249,3,242,51,252,55,224,11,224,3,240,15,240,57,248,57,252,0,250,0,113,192,1,192,1
0765   701A 0070C0F8C1F801F903F233FC37E00BE003F00FF039F839FC00FA0071C001C001
0766   703A                    defb 0,28,48,62,48,126,64,126,128,252,12,255,13,248,2,248,0,252,3,252,14,126,14,127,128,62,64,28,112,0,112,0
0766   703A 001C303E307E407E80FC0CFF0DF802F800FC03FC0E7E0E7F803E401C70007000
0767   705A                    defb 0,7,140,15,140,31,144,31,32,63,195,63,3,126,0,190,0,63,0,255,131,159,195,159,160,15,16,7,28,0,28,0
0767   705A 00078C0F8C1F901F203FC33F037E00BE003F00FF839FC39FA00F10071C001C00
0768   707A                    defb 1,192,3,224,7,224,199,227,207,207,63,240,15,128,15,128,15,192,7,192,55,232,47,244,227,231,225,199,0,0,0,0
0768   707A 01C003E007E0C7E3CFCF3FF00F800F800FC007C037E82FF4E3E7E1C700000000
0769   709A                    defb 0,112,0,248,1,248,241,248,243,243,15,252,3,224,3,224,3,240,1,240,13,250,11,253,248,249,248,113,0,0,0,0
0769   709A 007000F801F8F1F8F3F30FFC03E003E003F001F00DFA0BFDF8F9F87100000000
0770   70BA                    defb 0,28,0,62,0,126,60,126,252,252,3,255,0,248,0,248,0,252,0,124,131,126,66,255,126,62,126,28,0,0,0,0
0770   70BA 001C003E007E3C7EFCFC03FF00F800F800FC007C837E42FF7E3E7E1C00000000
0771   70DA                    defb 0,7,128,15,128,31,143,31,63,63,192,255,0,62,0,62,0,63,0,31,160,223,208,191,159,143,31,135,0,0,0,0
0771   70DA 0007800F801F8F1F3F3FC0FF003E003E003F001FA0DFD0BF9F8F1F8700000000
0772   70FA                    defb 31,240,63,252,95,254,79,62,110,31,76,159,253,127,215,255,83,255,127,223,47,30,138,184,160,96,234,224,255,224,127,192
0772   70FA 1FF03FFC5FFE4F3E6E1F4C9FFD7FD7FF53FF7FDF2F1E8AB8A060EAE0FFE07FC0
0773   711A                    defb 7,252,15,255,151,255,147,207,219,135,211,39,255,95,245,255,212,255,223,247,139,199,34,174,40,24,58,184,63,248,31,240
0773   711A 07FC0FFF97FF93CFDB87D327FF5FF5FFD4FFDFF78BC722AE28183AB83FF81FF0
0774   713A                    defb 1,255,195,255,229,255,228,243,246,225,244,201,255,215,253,127,245,63,247,253,226,241,136,171,10,6,14,174,15,254,7,252
0774   713A 01FFC3FFE5FFE4F3F6E1F4C9FFD7FD7FF53FF7FDE2F188AB0A060EAE0FFE07FC
0775   715A                    defb 192,127,240,255,249,127,249,60,125,184,125,50,255,245,255,95,253,79,125,255,120,188,226,42,130,129,131,171,131,255,1,255
0775   715A C07FF0FFF97FF93C7DB87D32FFF5FF5FFD4F7DFF78BCE22A828183AB83FF01FF
0776   717A                    defb 15,248,63,252,127,250,124,242,248,118,249,50,254,191,255,235,255,202,251,254,120,244,29,81,6,5,7,87,7,255,3,254
0776   717A 0FF83FFC7FFA7CF2F876F932FEBFFFEBFFCAFBFE78F41D510605075707FF03FE
0777   719A                    defb 3,254,15,255,159,254,159,60,190,29,190,76,255,175,255,250,191,242,190,255,30,61,71,84,65,129,193,213,193,255,128,255
0777   719A 03FE0FFF9FFE9F3CBE1DBE4CFFAFFFFABFF2BEFF1E3D47544181C1D5C1FF80FF
0778   71BA                    defb 128,255,195,255,167,255,39,207,111,135,47,147,255,235,191,254,175,252,239,191,71,143,17,213,80,96,112,117,240,127,224,63
0778   71BA 80FFC3FFA7FF27CF6F872F93FFEBBFFEAFFCEFBF478F11D550607075F07FE03F
0779   71DA                    defb 224,63,240,255,233,255,201,243,219,225,203,228,255,250,175,255,43,255,251,239,209,227,68,117,20,24,92,29,252,31,248,15
0779   71DA E03FF0FFE9FFC9F3DBE1CBE4FFFAAFFF2BFFFBEFD1E3447514185C1DFC1FF80F
0780   71FA                    defb 1,128,7,224,27,56,103,142,159,195,224,63,159,193,159,193,207,195,103,134,51,140,27,24,13,48,6,96,3,192,1,128
0780   71FA 018007E01B38678E9FC3E03F9FC19FC1CFC36786338C1B180D30066003C00180
0781   721A                    defb 0,96,1,248,6,206,153,227,231,240,248,15,103,240,103,240,243,240,153,225,12,227,6,198,3,76,1,152,0,240,0,96
0781   721A 006001F806CE99E3E7F0F80F67F067F0F3F099E10CE306C6034C019800F00060
0782   723A                    defb 0,24,0,126,129,179,230,120,57,252,254,3,25,252,25,252,60,252,102,120,195,56,129,177,0,211,0,102,0,60,0,24
0782   723A 0018007E81B3E67839FCFE0319FC19FC3CFC6678C33881B100D30066003C0018
0783   725A                    defb 0,6,128,31,224,108,57,158,14,127,255,128,6,127,6,127,15,63,25,158,48,206,96,108,192,52,128,25,0,15,0,6
0783   725A 0006801FE06C399E0E7FFF80067F067F0F3F199E30CE606CC0348019000F0006
0784   727A             frmlst equ $
0785   727A 00 04              defb 0,4
0786   727C 04 04              defb 4,4
0787   727E 08 02              defb 8,2
0788   7280 0A 01 0B 00        defb 10,1,11,0
0789   7284             nmedat defb 0,0,104,120,1,2,128,16,2,3,152,16,2,3,56,80,2,3,80,160,2,3,32,16,255
0789   7284 00006878010280100203981002033850020350A002032010FF
0790   729D                    defb 0,0,80,64,1,2,128,16,1,2,32,16,2,3,32,80,2,3,56,112,2,3,80,128,2,3,128,88,255
0790   729D 00005040010280100102201002032050020338700203508002038058FF
0791   72BA                    defb 0,0,64,136,1,2,40,56,1,2,112,64,2,3,16,40,2,3,16,128,2,3,88,152,2,3,136,88,2,3,160,16,2,3,160,160,255
0791   72BA 000040880102283801027040020310280203108002035898020388580203A010
0791   72DA 0203A0A0FF
0792   72DF                    defb 0,0,160,16,1,2,16,104,1,2,64,80,1,2,112,112,2,3,16,16,2,3,88,16,2,3,136,160,2,3,16,152,2,3,64,24,255
0792   72DF 0000A0100102106801024050010270700203101002035810020388A002031098
0792   72FF 02034018FF
0793   7304                    defb 0,0,112,160,1,2,88,72,1,2,16,160,1,2,160,64,2,3,88,160,2,3,40,40,2,3,16,64,2,3,160,104,255
0793   7304 000070A001025848010210A00102A040020358A002032828020310400203A068
0793   7324 FF
0794   7325                    defb 0,0,88,88,1,2,16,160,1,2,136,16,1,2,112,160,2,3,40,160,2,3,64,16,2,3,40,16,2,3,136,88,2,3,160,136,255
0794   7325 00005858010210A001028810010270A0020328A0020340100203281002038858
0794   7345 0203A088FF
0795   734A             NUMOBJ equ 1
0796   734A             objdta equ $
0797   734A                    defb 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,15,254,56,120,254,56,120
0797   734A 0000000000000000000000000000000000000000000000000000000000000000
0797   736A 0FFE3878FE3878
0798   7371             palett equ $
0799   7371                    defb 0,3,28,31,224,227,252,255,0,15,156,16,248,131,190,253
0799   7371 00031C1FE0E3FCFF000F9C10F883BEFD
0800   7381                    defb 0,3,28,31,224,227,252,255,0,15,156,16,248,131,190,253
0800   7381 00031C1FE0E3FCFF000F9C10F883BEFD
0801   7391                    defb 0,3,28,31,224,227,252,255,0,15,156,16,248,131,190,253
0801   7391 00031C1FE0E3FCFF000F9C10F883BEFD
0802   73A1                    defb 0,3,28,31,224,227,252,255,0,15,156,16,248,131,190,253
0802   73A1 00031C1FE0E3FCFF000F9C10F883BEFD
0803   73B1             font   equ $
0804   73B1                    defb 0,0,0,0,0,0,0,0
0804   73B1 0000000000000000
0805   73B9                    defb 0,32,32,32,32,0,32,0
0805   73B9 0020202020002000
0806   73C1                    defb 80,80,0,0,0,0,0,0
0806   73C1 5050000000000000
0807   73C9                    defb 0,80,248,80,248,80,0,0
0807   73C9 0050F850F8500000
0808   73D1                    defb 32,112,192,96,48,224,32,0
0808   73D1 2070C06030E02000
0809   73D9                    defb 0,160,32,64,64,128,160,0
0809   73D9 00A020404080A000
0810   73E1                    defb 0,64,160,64,176,160,112,0
0810   73E1 0040A040B0A07000
0811   73E9                    defb 64,64,0,0,0,0,0,0
0811   73E9 4040000000000000
0812   73F1                    defb 0,32,64,64,64,64,32,0
0812   73F1 0020404040402000
0813   73F9                    defb 0,64,32,32,32,32,64,0
0813   73F9 0040202020204000
0814   7401                    defb 0,32,248,112,248,32,0,0
0814   7401 0020F870F8200000
0815   7409                    defb 0,64,64,224,64,64,0,0
0815   7409 004040E040400000
0816   7411                    defb 0,0,0,0,0,0,32,64
0816   7411 0000000000002040
0817   7419                    defb 0,0,0,224,0,0,0,0
0817   7419 000000E000000000
0818   7421                    defb 0,0,0,0,0,0,64,0
0818   7421 0000000000004000
0819   7429                    defb 0,32,32,64,64,128,128,0
0819   7429 0020204040808000
0820   7431                    defb 0,96,144,176,208,144,96,0
0820   7431 006090B0D0906000
0821   7439                    defb 0,64,192,64,64,64,224,0
0821   7439 0040C0404040E000
0822   7441                    defb 0,96,144,16,96,128,240,0
0822   7441 006090106080F000
0823   7449                    defb 0,96,144,32,16,144,96,0
0823   7449 0060902010906000
0824   7451                    defb 0,32,96,160,240,32,32,0
0824   7451 002060A0F0202000
0825   7459                    defb 0,240,128,224,16,16,224,0
0825   7459 00F080E01010E000
0826   7461                    defb 0,96,128,224,144,144,96,0
0826   7461 006080E090906000
0827   7469                    defb 0,240,16,32,32,64,64,0
0827   7469 00F0102020404000
0828   7471                    defb 0,96,144,96,144,144,96,0
0828   7471 0060906090906000
0829   7479                    defb 0,96,144,144,112,16,96,0
0829   7479 0060909070106000
0830   7481                    defb 0,0,64,0,0,64,0,0
0830   7481 0000400000400000
0831   7489                    defb 0,0,64,0,0,64,128,0
0831   7489 0000400000408000
0832   7491                    defb 0,0,32,64,128,64,32,0
0832   7491 0000204080402000
0833   7499                    defb 0,0,128,64,32,64,128,0
0833   7499 0000804020408000
0834   74A1                    defb 0,0,0,224,0,224,0,0
0834   74A1 000000E000E00000
0835   74A9                    defb 0,224,16,32,64,0,64,0
0835   74A9 00E0102040004000
0836   74B1                    defb 0,96,144,176,176,128,112,0
0836   74B1 006090B0B0807000
0837   74B9                    defb 0,96,144,144,240,144,144,0
0837   74B9 00609090F0909000
0838   74C1                    defb 0,224,144,224,144,144,224,0
0838   74C1 00E090E09090E000
0839   74C9                    defb 0,96,144,128,128,144,96,0
0839   74C9 0060908080906000
0840   74D1                    defb 0,192,160,144,144,144,224,0
0840   74D1 00C0A0909090E000
0841   74D9                    defb 0,240,128,224,128,128,240,0
0841   74D9 00F080E08080F000
0842   74E1                    defb 0,240,128,224,128,128,128,0
0842   74E1 00F080E080808000
0843   74E9                    defb 0,96,144,128,176,144,112,0
0843   74E9 00609080B0907000
0844   74F1                    defb 0,144,144,240,144,144,144,0
0844   74F1 009090F090909000
0845   74F9                    defb 0,224,64,64,64,64,224,0
0845   74F9 00E040404040E000
0846   7501                    defb 0,48,16,16,16,144,96,0
0846   7501 0030101010906000
0847   7509                    defb 0,144,160,192,160,144,144,0
0847   7509 0090A0C0A0909000
0848   7511                    defb 0,128,128,128,128,128,240,0
0848   7511 008080808080F000
0849   7519                    defb 0,136,216,168,136,136,136,0
0849   7519 0088D8A888888800
0850   7521                    defb 0,144,208,208,176,176,144,0
0850   7521 0090D0D0B0B09000
0851   7529                    defb 0,96,144,144,144,144,96,0
0851   7529 0060909090906000
0852   7531                    defb 0,224,144,144,224,128,128,0
0852   7531 00E09090E0808000
0853   7539                    defb 0,96,144,144,176,144,112,0
0853   7539 00609090B0907000
0854   7541                    defb 0,224,144,160,192,160,144,0
0854   7541 00E090A0C0A09000
0855   7549                    defb 0,112,128,64,32,16,224,0
0855   7549 007080402010E000
0856   7551                    defb 0,248,32,32,32,32,32,0
0856   7551 00F8202020202000
0857   7559                    defb 0,144,144,144,144,144,96,0
0857   7559 0090909090906000
0858   7561                    defb 0,136,136,80,80,32,32,0
0858   7561 0088885050202000
0859   7569                    defb 0,136,136,136,168,168,80,0
0859   7569 00888888A8A85000
0860   7571                    defb 0,144,144,96,96,144,144,0
0860   7571 0090906060909000
0861   7579                    defb 0,136,136,80,32,32,32,0
0861   7579 0088885020202000
0862   7581                    defb 0,240,16,32,64,128,240,0
0862   7581 00F010204080F000
0863   7589                    defb 0,96,64,64,64,64,96,0
0863   7589 0060404040406000
0864   7591                    defb 0,128,128,64,64,32,32,0
0864   7591 0080804040202000
0865   7599                    defb 0,96,32,32,32,32,96,0
0865   7599 0060202020206000
0866   75A1                    defb 64,160,0,0,0,0,0,0
0866   75A1 40A0000000000000
0867   75A9                    defb 0,0,0,0,0,0,0,248
0867   75A9 00000000000000F8
0868   75B1                    defb 48,64,64,224,64,64,240,0
0868   75B1 304040E04040F000
0869   75B9                    defb 0,224,16,112,144,144,112,0
0869   75B9 00E0107090907000
0870   75C1                    defb 0,128,128,224,144,144,224,0
0870   75C1 008080E09090E000
0871   75C9                    defb 0,0,96,128,128,144,96,0
0871   75C9 0000608080906000
0872   75D1                    defb 0,16,16,112,144,144,112,0
0872   75D1 0010107090907000
0873   75D9                    defb 0,0,96,144,240,128,112,0
0873   75D9 00006090F0807000
0874   75E1                    defb 0,48,64,224,64,64,64,0
0874   75E1 003040E040404000
0875   75E9                    defb 0,0,112,144,144,112,16,96
0875   75E9 0000709090701060
0876   75F1                    defb 0,128,128,128,224,144,144,0
0876   75F1 00808080E0909000
0877   75F9                    defb 0,64,0,192,64,64,224,0
0877   75F9 004000C04040E000
0878   7601                    defb 0,32,0,96,32,32,32,192
0878   7601 00200060202020C0
0879   7609                    defb 0,128,144,160,192,160,144,0
0879   7609 008090A0C0A09000
0880   7611                    defb 0,64,64,64,64,64,32,0
0880   7611 0040404040402000
0881   7619                    defb 0,0,80,168,168,136,136,0
0881   7619 000050A8A8888800
0882   7621                    defb 0,0,224,144,144,144,144,0
0882   7621 0000E09090909000
0883   7629                    defb 0,0,96,144,144,144,96,0
0883   7629 0000609090906000
0884   7631                    defb 0,0,224,144,144,224,128,128
0884   7631 0000E09090E08080
0885   7639                    defb 0,0,112,144,144,112,16,16
0885   7639 0000709090701010
0886   7641                    defb 0,0,96,128,128,128,128,0
0886   7641 0000608080808000
0887   7649                    defb 0,0,112,128,96,16,224,0
0887   7649 000070806010E000
0888   7651                    defb 0,64,224,64,64,64,32,0
0888   7651 0040E04040402000
0889   7659                    defb 0,0,144,144,144,144,96,0
0889   7659 0000909090906000
0890   7661                    defb 0,0,136,136,80,80,32,0
0890   7661 0000888850502000
0891   7669                    defb 0,0,136,136,136,168,80,0
0891   7669 0000888888A85000
0892   7671                    defb 0,0,144,144,96,144,144,0
0892   7671 0000909060909000
0893   7679                    defb 0,0,144,144,144,112,16,224
0893   7679 00009090907010E0
0894   7681                    defb 0,0,240,32,64,128,240,0
0894   7681 0000F0204080F000
0895   7689                    defb 0,96,64,192,64,64,96,0
0895   7689 006040C040406000
0896   7691                    defb 0,64,64,64,64,64,64,0
0896   7691 0040404040404000
0897   7699                    defb 0,192,64,96,64,64,192,0
0897   7699 00C040604040C000
0898   76A1                    defb 0,80,160,0,0,0,0,0
0898   76A1 0050A00000000000
0899   76A9                    defb 112,136,32,64,64,32,136,112
0899   76A9 7088204040208870
0900   76B1             jtab   equ $
0901   76B1 63                 defb 99
0902   76B2             keys   defb 35,27,29,28,16,31,1,36,28,20,12
0902   76B2 231B1D1C101F01241C140C
0903   76BD E6 03       dig    and 3
0904   76BF 28 31              jr z,digl
0905   76C1 3D                 dec a
0906   76C2 28 52              jr z,digr
0907   76C4 3D                 dec a
0908   76C5 28 0B              jr z,digu
0909   76C7 DD 66 09           ld h,(ix+9)
0910   76CA 3E 10              ld a,16
0911   76CC DD 86 08           add a,(ix+8)
0912   76CF 6F                 ld l,a
0913   76D0 18 09              jr digv
0914   76D2 DD 7E 08    digu   ld a,(ix+8)
0915   76D5 DD 66 09           ld h,(ix+9)
0916   76D8 D6 02              sub 2
0917   76DA 6F                 ld l,a
0918   76DB 22 5B 77    digv   ld (dispx),hl
0919   76DE CD E7 85           call tstbl
0920   76E1 CD 58 7A           call fdchk
0921   76E4 23                 inc hl
0922   76E5 CD 58 7A           call fdchk
0923   76E8 3A 5C 77           ld a,(dispy)
0924   76EB E6 07              and 7
0925   76ED C8                 ret z
0926   76EE 23                 inc hl
0927   76EF C3 58 7A           jp fdchk
0928   76F2 DD 6E 08    digl   ld l,(ix+8)
0929   76F5 DD 7E 09           ld a,(ix+9)
0930   76F8 D6 02              sub 2
0931   76FA 67                 ld h,a
0932   76FB 22 5B 77    digh   ld (dispx),hl
0933   76FE 7D                 ld a,l
0934   76FF E6 07              and 7
0935   7701 3E 03              ld a,3
0936   7703 20 01              jr nz,digh1
0937   7705 3D                 dec a
0938   7706 47          digh1  ld b,a
0939   7707 CD E7 85           call tstbl
0940   770A C5          digh0  push bc
0941   770B CD 58 7A           call fdchk
0942   770E 11 20 00           ld de,32
0943   7711 19                 add hl,de
0944   7712 C1                 pop bc
0945   7713 10 F5              djnz digh0
0946   7715 C9                 ret
0947   7716 DD 6E 08    digr   ld l,(ix+8)
0948   7719 DD 7E 09           ld a,(ix+9)
0949   771C C6 10              add a,16
0950   771E 67                 ld h,a
0951   771F 18 DA              jr digh
0952   7721             
0953   7721             
0954   7721             ; Game engine code --------------------------------------------------------------
0955   7721             
0956   7721             ; Arcade Game Designer.
0957   7721             ; (C) 2008 - 2020 Jonathan Cauldwell.
0958   7721             ; ZX Spectrum Engine v0.7.10
0959   7721             
0960   7721             ; Global definitions.
0961   7721             
0962   7721             SIMASK equ 248             ; SPRITEINK mask - allows users to set BRIGHT/FLASH/CLUT as well.
0963   7721             SHRAPN equ 63926           ; shrapnel table, just below screen address table.
0964   7721             SCADTB equ 64256           ; screen address table, just below map.
0965   7721             MAP    equ 64768           ; properties map buffer.
0966   7721             loopa  equ 23681           ; loop counter system variable.
0967   7721             loopb  equ 23728           ; loop counter system variable.
0968   7721             loopc  equ 23729           ; loop counter system variable.
0969   7721             
0970   7721             ; Block characteristics.
0971   7721             
0972   7721             PLATFM equ 1               ; platform.
0973   7721             WALL   equ PLATFM + 1      ; solid wall.
0974   7721             LADDER equ WALL + 1        ; ladder.
0975   7721             FODDER equ LADDER + 1      ; fodder block.
0976   7721             DEADLY equ FODDER + 1      ; deadly block.
0977   7721             CUSTOM equ DEADLY + 1      ; custom block.
0978   7721             WATER  equ CUSTOM + 1      ; water block.
0979   7721             COLECT equ WATER + 1       ; collectable block.
0980   7721             NUMTYP equ COLECT + 1      ; number of types.
0981   7721             
0982   7721             ; Sprites.
0983   7721             
0984   7721             NUMSPR equ 12              ; number of sprites.
0985   7721             TABSIZ equ 17              ; size of each entry.
0986   7721             SPRBUF equ NUMSPR * TABSIZ ; size of entire table.
0987   7721             NMESIZ equ 4               ; bytes stored in nmetab for each sprite.
0988   7721             X      equ 8               ; new x coordinate of sprite.
0989   7721             Y      equ X + 1           ; new y coordinate of sprite.
0990   7721             PAM1ST equ 5               ; first sprite parameter, old x (ix+5).
0991   7721             
0992   7721             ; Particle engine.
0993   7721             
0994   7721             NUMSHR equ 55              ; pieces of shrapnel.
0995   7721             SHRSIZ equ 6               ; bytes per particle.
0996   7721             
0997   7721             
0998   7721             ; Game starts here.
0999   7721             ; Musicizer relies on distance between start and varm remaining constant at 34 bytes.
1000   7721             ; Do not mess with this section or users will be unable to control music with the M variable.
1001   7721             
1002   7721             start  equ $
1003   7721             
1004   7721             ; Set up the font.
1005   7721             
1006   7721 21 B1 72           ld hl,font-256      ; address of font.
1007   7724 22 36 5C           ld (23606),hl       ; set up game font.
1008   7727             
1009   7727             ; if you wish to exit to BASIC at the end of each game, change "jp gamelp" to "jp game".
1010   7727 C3 DA 7D           jp gamelp           ; start the game.
1011   772A             
1012   772A 00          joyval defb 0              ; joystick reading.
1013   772B 00          frmno  defb 0              ; selected frame.
1014   772C             
1015   772C             ; Don't change the order of these four.  Menu routine relies on winlft following wintop.
1016   772C             
1017   772C 01          wintop defb WINDOWTOP      ; top of window.
1018   772D 01          winlft defb WINDOWLFT      ; left edge.
1019   772E 16          winhgt defb WINDOWHGT      ; window height.
1020   772F 16          winwid defb WINDOWWID      ; window width.
1021   7730             
1022   7730 01          numob  defb NUMOBJ         ; number of objects in game.
1023   7731             
1024   7731             ; Variables start here.
1025   7731             ; Pixel versions of wintop, winlft, winhgt, winwid.
1026   7731             
1027   7731 08          wntopx defb (8 * WINDOWTOP)
1028   7732 08          wnlftx defb (8 * WINDOWLFT)
1029   7733 A8          wnbotx defb ((WINDOWTOP * 8) + (WINDOWHGT * 8) - 16)
1030   7734 A8          wnrgtx defb ((WINDOWLFT * 8) + (WINDOWWID * 8) - 16)
1031   7735 00          scno   defb 0              ; present screen number.
1032   7736 03          numlif defb 3              ; number of lives.
1033   7737 00          vara   defb 0              ; general-purpose variable.
1034   7738 00          varb   defb 0              ; general-purpose variable.
1035   7739 00          varc   defb 0              ; general-purpose variable.
1036   773A 00          vard   defb 0              ; general-purpose variable.
1037   773B 00          vare   defb 0              ; general-purpose variable.
1038   773C 00          varf   defb 0              ; general-purpose variable.
1039   773D 00          varg   defb 0              ; general-purpose variable.
1040   773E 00          varh   defb 0              ; general-purpose variable.
1041   773F 00          vari   defb 0              ; general-purpose variable.
1042   7740 00          varj   defb 0              ; general-purpose variable.
1043   7741 00          vark   defb 0              ; general-purpose variable.
1044   7742 00          varl   defb 0              ; general-purpose variable.
1045   7743 00          varm   defb 0              ; general-purpose variable.
1046   7744 00          varn   defb 0              ; general-purpose variable.
1047   7745 00          varo   defb 0              ; general-purpose variable.
1048   7746 00          varp   defb 0              ; general-purpose variable.
1049   7747 00          varq   defb 0              ; general-purpose variable.
1050   7748 00          varr   defb 0              ; general-purpose variable.
1051   7749 00          vars   defb 0              ; general-purpose variable.
1052   774A 00          vart   defb 0              ; general-purpose variable.
1053   774B 00          varu   defb 0              ; general-purpose variable.
1054   774C 00          varv   defb 0              ; general-purpose variable.
1055   774D 00          varw   defb 0              ; general-purpose variable.
1056   774E 00          varz   defb 0              ; general-purpose variable.
1057   774F 00          contrl defb 0              ; control, 0 = keyboard, 1 = Kempston, 2 = Sinclair, 3 = Mouse.
1058   7750 00          charx  defb 0              ; cursor x position.
1059   7751 00          chary  defb 0              ; cursor y position.
1060   7752 00          clock  defb 0              ; last clock reading.
1061   7753 FF          varrnd defb 255            ; last random number.
1062   7754 FE          varobj defb 254            ; last object number.
1063   7755 FF          varopt defb 255            ; last option chosen from menu.
1064   7756 FF          varblk defb 255            ; block type.
1065   7757 00          nexlev defb 0              ; next level flag.
1066   7758 00          restfl defb 0              ; restart screen flag.
1067   7759 00          deadf  defb 0              ; dead flag.
1068   775A 00          gamwon defb 0              ; game won flag.
1069   775B 00          dispx  defb 0              ; cursor x position.
1070   775C 00          dispy  defb 0              ; cursor y position.
1071   775D             
1072   775D             ; Make sure pointers are arranged in the same order as the data itself.
1073   775D             
1074   775D 7A 72       frmptr defw frmlst         ; sprite frames.
1075   775F C8 6C       blkptr defw chgfx          ; block graphics.
1076   7761 F0 6C       colptr defw bcol           ; address of char colours.
1077   7763 F5 6C       proptr defw bprop          ; address of char properties.
1078   7765 E7 66       scrptr defw scdat          ; address of screens.
1079   7767 84 72       nmeptr defw nmedat         ; enemy start positions.
1080   7769             
1081   7769             ; Assorted game routines which can go in contended memory.
1082   7769             
1083   7769             ; Modify for inventory.
1084   7769             
1085   7769 21 E9 78    minve  ld hl,invdis        ; routine address.
1086   776C 22 F4 77           ld (mod0+1),hl      ; set up menu routine.
1087   776F 22 9A 77           ld (mod2+1),hl      ; set up count routine.
1088   7772 21 F6 78           ld hl,fopt          ; find option from available objects.
1089   7775 22 7C 78           ld (mod1+1),hl      ; set up routine.
1090   7778 18 0F              jr dbox             ; do menu routine.
1091   777A             
1092   777A             ; Modify for menu.
1093   777A             
1094   777A 21 14 85    mmenu  ld hl,always        ; routine address.
1095   777D 22 F4 77           ld (mod0+1),hl      ; set up routine.
1096   7780 22 9A 77           ld (mod2+1),hl      ; set up count routine.
1097   7783 21 AB 78           ld hl,fstd          ; standard option selection.
1098   7786 22 7C 78           ld (mod1+1),hl      ; set up routine.
1099   7789             
1100   7789             ; Drop through into box routine.
1101   7789             
1102   7789             ; Work out size of box for message or menu.
1103   7789             
1104   7789             ;dbox   ld hl,nummsg        ; total messages.
1105   7789             ;       cp (hl)             ; does this one exist?
1106   7789             ;       ret nc              ; no, nothing to display.
1107   7789 21 91 66    dbox   ld hl,msgdat        ; pointer to messages.
1108   778C CD A4 87           call getwrd         ; get message number.
1109   778F E5                 push hl             ; store pointer to message.
1110   7790 16 01              ld d,1              ; height.
1111   7792 AF                 xor a               ; start at object zero.
1112   7793 32 5E 84           ld (combyt),a       ; store number of object in combyt.
1113   7796 5F                 ld e,a              ; maximum width.
1114   7797 06 00       dbox5  ld b,0              ; this line's width.
1115   7799 CD 14 85    mod2   call always         ; item in player's possession?
1116   779C 20 01              jr nz,dbox6         ; not in inventory, skip this line.
1117   779E 14                 inc d               ; add to tally.
1118   779F 7E          dbox6  ld a,(hl)           ; get character.
1119   77A0 23                 inc hl              ; next character.
1120   77A1 FE 2C              cp ','              ; reached end of line?
1121   77A3 28 0B              jr z,dbox3          ; yes.
1122   77A5 FE 0D              cp 13               ; reached end of line?
1123   77A7 28 07              jr z,dbox3          ; yes.
1124   77A9 04                 inc b               ; add to this line's width.
1125   77AA A7                 and a               ; end of message?
1126   77AB FA B7 77           jp m,dbox4          ; yes, end count.
1127   77AE 18 EF              jr dbox6            ; repeat until we find the end.
1128   77B0 7B          dbox3  ld a,e              ; maximum line width.
1129   77B1 B8                 cp b                ; have we exceeded longest so far?
1130   77B2 30 E3              jr nc,dbox5         ; no, carry on looking.
1131   77B4 58                 ld e,b              ; make this the widest so far.
1132   77B5 18 E0              jr dbox5            ; keep looking.
1133   77B7 7B          dbox4  ld a,e              ; maximum line width.
1134   77B8 B8                 cp b                ; have we exceeded longest so far?
1135   77B9 30 01              jr nc,dbox8         ; no, carry on looking.
1136   77BB 58                 ld e,b              ; final line is the longest so far.
1137   77BC 15          dbox8  dec d               ; decrement items found.
1138   77BD CA CA 78           jp z,dbox15         ; total was zero.
1139   77C0 7B                 ld a,e              ; longest line.
1140   77C1 A7                 and a               ; was it zero?
1141   77C2 CA CA 78           jp z,dbox15         ; total was zero.
1142   77C5 ED 53 21 79        ld (bwid),de        ; set up size.
1143   77C9             
1144   77C9             ; That's set up our box size.
1145   77C9             
1146   77C9 3A 2E 77           ld a,(winhgt)       ; window height in characters.
1147   77CC 92                 sub d               ; subtract height of box.
1148   77CD 1F                 rra                 ; divide by 2.
1149   77CE 21 2C 77           ld hl,wintop        ; top edge of window.
1150   77D1 86                 add a,(hl)          ; add displacement.
1151   77D2 32 23 79           ld (btop),a         ; set up box top.
1152   77D5 3A 2F 77           ld a,(winwid)       ; window width in characters.
1153   77D8 93                 sub e               ; subtract box width.
1154   77D9 1F                 rra                 ; divide by 2.
1155   77DA 23                 inc hl              ; left edge of window.
1156   77DB 86                 add a,(hl)          ; add displacement.
1157   77DC 32 24 79           ld (blft),a         ; box left.
1158   77DF 2A 36 5C           ld hl,(23606)       ; font.
1159   77E2 22 2E 82           ld (grbase),hl      ; set up for text display.
1160   77E5 E1                 pop hl              ; restore message pointer.
1161   77E6 3A 23 79           ld a,(btop)         ; box top.
1162   77E9 32 5B 77           ld (dispx),a        ; set display coordinate.
1163   77EC AF                 xor a               ; start at object zero.
1164   77ED 32 5E 84           ld (combyt),a       ; store number of object in combyt.
1165   77F0 3A 5E 84    dbox2  ld a,(combyt)       ; get object number.
1166   77F3 CD 14 85    mod0   call always         ; check inventory for display.
1167   77F6 C2 B8 78           jp nz,dbox13        ; not in inventory, skip this line.
1168   77F9             
1169   77F9 3A 24 79           ld a,(blft)         ; box left.
1170   77FC 32 5C 77           ld (dispy),a        ; set left display position.
1171   77FF 3A 21 79           ld a,(bwid)         ; box width.
1172   7802 47                 ld b,a              ; store width.
1173   7803 7E          dbox0  ld a,(hl)           ; get character.
1174   7804 FE 2C              cp ','              ; end of line?
1175   7806 28 45              jr z,dbox1          ; yes, next one.
1176   7808 FE 0D              cp 13               ; end of option?
1177   780A 28 41              jr z,dbox1          ; yes, on to next.
1178   780C 05                 dec b               ; one less to display.
1179   780D E6 7F              and 127             ; remove terminator.
1180   780F C5                 push bc             ; store characters remaining.
1181   7810 E5                 push hl             ; store address on stack.
1182   7811 F5                 push af             ; store character.
1183   7812 CD 0E 83           call gaadd          ; get attribute address.
1184   7815 3A 8D 5C           ld a,(23693)        ; current colour.
1185   7818 77                 ld (hl),a           ; set attribute.
1186   7819 F1                 pop af              ; restore character.
1187   781A CD 7D 83           call pchr           ; display on screen.
1188   781D E1                 pop hl              ; retrieve address of next character.
1189   781E C1                 pop bc              ; chars left for this line.
1190   781F 7E                 ld a,(hl)           ; get character.
1191   7820 23                 inc hl              ; next character.
1192   7821 FE 80              cp 128              ; end of message?
1193   7823 D2 5B 78           jp nc,dbox7         ; yes, job done.
1194   7826 78                 ld a,b              ; chars remaining.
1195   7827 A7                 and a               ; are any left?
1196   7828 20 D9              jr nz,dbox0         ; yes, continue.
1197   782A             
1198   782A             ; Reached limit of characters per line.
1199   782A             
1200   782A 7E          dbox9  ld a,(hl)           ; get character.
1201   782B 23                 inc hl              ; next one.
1202   782C FE 2C              cp ','              ; another line?
1203   782E 28 21              jr z,dbox10         ; yes, do next line.
1204   7830 FE 0D              cp 13               ; another line?
1205   7832 28 1D              jr z,dbox10         ; yes, on to next.
1206   7834 FE 80              cp 128              ; end of message?
1207   7836 30 2A              jr nc,dbox11        ; yes, finish message.
1208   7838 18 F0              jr dbox9
1209   783A             
1210   783A             ; Fill box to end of line.
1211   783A             
1212   783A E5          dboxf  push hl             ; store address on stack.
1213   783B C5                 push bc             ; store characters remaining.
1214   783C CD 0E 83           call gaadd          ; get attribute address.
1215   783F 3A 8D 5C           ld a,(23693)        ; current colour.
1216   7842 77                 ld (hl),a           ; set attribute.
1217   7843 3E 20              ld a,32             ; space character.
1218   7845 CD 7D 83           call pchr           ; display character.
1219   7848 C1                 pop bc              ; retrieve character count.
1220   7849 E1                 pop hl              ; retrieve address of next character.
1221   784A 10 EE              djnz dboxf          ; repeat for remaining chars on line.
1222   784C C9                 ret
1223   784D 23          dbox1  inc hl              ; skip character.
1224   784E CD 3A 78           call dboxf          ; fill box out to right side.
1225   7851 3A 5B 77    dbox10 ld a,(dispx)        ; x coordinate.
1226   7854 3C                 inc a               ; down a line.
1227   7855 32 5B 77           ld (dispx),a        ; next position.
1228   7858 C3 F0 77           jp dbox2            ; next line.
1229   785B 78          dbox7  ld a,b              ; chars remaining.
1230   785C A7                 and a               ; are any left?
1231   785D 28 03              jr z,dbox11         ; no, nothing to draw.
1232   785F CD 3A 78           call dboxf          ; fill message to line.
1233   7862             
1234   7862             ; Drawn the box menu, now select option.
1235   7862             
1236   7862 3A 23 79    dbox11 ld a,(btop)         ; box top.
1237   7865 32 5B 77           ld (dispx),a        ; set bar position.
1238   7868 CD 4F 86    dbox14 call joykey         ; get controls.
1239   786B E6 1F              and 31              ; anything pressed?
1240   786D 20 F9              jr nz,dbox14        ; yes, debounce it.
1241   786F CD CC 78           call dbar           ; draw bar.
1242   7872 CD 4F 86    dbox12 call joykey         ; get controls.
1243   7875 E6 1C              and 28              ; anything pressed?
1244   7877 28 F9              jr z,dbox12         ; no, nothing.
1245   7879 E6 10              and 16              ; fire button pressed?
1246   787B C2 AB 78    mod1   jp nz,fstd          ; yes, job done.
1247   787E CD CC 78           call dbar           ; delete bar.
1248   7881 3A 2A 77           ld a,(joyval)       ; joystick reading.
1249   7884 E6 08              and 8               ; going up?
1250   7886 20 13              jr nz,dboxu         ; yes, go up.
1251   7888 3A 5B 77           ld a,(dispx)        ; vertical position of bar.
1252   788B 3C                 inc a               ; look down.
1253   788C 21 23 79           ld hl,btop          ; top of box.
1254   788F 96                 sub (hl)            ; find distance from top.
1255   7890 2B                 dec hl              ; point to height.
1256   7891 BE                 cp (hl)             ; are we at end?
1257   7892 CA 68 78           jp z,dbox14         ; yes, go no further.
1258   7895 21 5B 77           ld hl,dispx         ; coordinate.
1259   7898 34                 inc (hl)            ; move bar.
1260   7899 18 CD              jr dbox14           ; continue.
1261   789B 3A 5B 77    dboxu  ld a,(dispx)        ; vertical position of bar.
1262   789E 21 23 79           ld hl,btop          ; top of box.
1263   78A1 BE                 cp (hl)             ; are we at the top?
1264   78A2 CA 68 78           jp z,dbox14         ; yes, go no further.
1265   78A5 21 5B 77           ld hl,dispx         ; coordinate.
1266   78A8 35                 dec (hl)            ; move bar.
1267   78A9 18 BD              jr dbox14           ; continue.
1268   78AB 3A 5B 77    fstd   ld a,(dispx)        ; bar position.
1269   78AE 21 23 79           ld hl,btop          ; top of menu.
1270   78B1 96                 sub (hl)            ; find selected option.
1271   78B2 32 55 77           ld (varopt),a       ; store the option.
1272   78B5 C3 E7 79           jp redraw           ; redraw the screen.
1273   78B8             
1274   78B8             ; Option not available.  Skip this line.
1275   78B8             
1276   78B8 7E          dbox13 ld a,(hl)           ; get character.
1277   78B9 23                 inc hl              ; next one.
1278   78BA FE 2C              cp ','              ; another line?
1279   78BC CA F0 77           jp z,dbox2          ; yes, do next line.
1280   78BF FE 0D              cp 13               ; another line?
1281   78C1 CA F0 77           jp z,dbox2          ; yes, on to next line.
1282   78C4 A7                 and a               ; end of message?
1283   78C5 FA 62 78           jp m,dbox11         ; yes, finish message.
1284   78C8 18 EE              jr dbox13
1285   78CA E1          dbox15 pop hl              ; pop message pointer from the stack.
1286   78CB C9                 ret
1287   78CC             
1288   78CC 3A 24 79    dbar   ld a,(blft)         ; box left.
1289   78CF 32 5C 77           ld (dispy),a        ; set display coordinate.
1290   78D2 CD E0 82           call gprad          ; get printing address.
1291   78D5 EB                 ex de,hl            ; flip into hl register pair.
1292   78D6 3A 21 79           ld a,(bwid)         ; box width.
1293   78D9 4F                 ld c,a              ; loop counter in c.
1294   78DA 54                 ld d,h              ; store screen address high byte.
1295   78DB 06 08       dbar1  ld b,8              ; pixel height in b.
1296   78DD 7E          dbar0  ld a,(hl)           ; get screen byte.
1297   78DE 2F                 cpl                 ; reverse all bits.
1298   78DF 77                 ld (hl),a           ; write back to screen.
1299   78E0 24                 inc h               ; next line down.
1300   78E1 10 FA              djnz dbar0          ; draw rest of character.
1301   78E3 62                 ld h,d              ; rsetore screen address.
1302   78E4 2C                 inc l               ; one char right.
1303   78E5 0D                 dec c               ; decrement character counter.
1304   78E6 20 F3              jr nz,dbar1         ; repeat for whole line.
1305   78E8 C9                 ret
1306   78E9             
1307   78E9 E5          invdis push hl             ; store message text pointer.
1308   78EA D5                 push de             ; store de pair for line count.
1309   78EB 21 5E 84           ld hl,combyt        ; object number.
1310   78EE 7E                 ld a,(hl)           ; get object number.
1311   78EF 34                 inc (hl)            ; ready for next one.
1312   78F0 CD 49 81           call gotob          ; check if we have object.
1313   78F3 D1                 pop de              ; retrieve de pair from stack.
1314   78F4 E1                 pop hl              ; retrieve text pointer.
1315   78F5 C9                 ret
1316   78F6             ;always xor a               ; set zero flag.
1317   78F6             ;       ret
1318   78F6             
1319   78F6             ; Find option selected.
1320   78F6             
1321   78F6 3A 5B 77    fopt   ld a,(dispx)
1322   78F9 21 23 79           ld hl,btop          ; top of menu.
1323   78FC 96                 sub (hl)            ; find selected option.
1324   78FD 3C                 inc a               ; object 0 needs one iteration, 1 needs 2 and so on.
1325   78FE 47                 ld b,a              ; option selected in b register.
1326   78FF 21 5E 84           ld hl,combyt        ; object number.
1327   7902 36 00              ld (hl),0           ; set to first item.
1328   7904 C5          fopt0  push bc             ; store option counter in b register.
1329   7905 CD 15 79           call fobj           ; find next object in inventory.
1330   7908 C1                 pop bc              ; restore option counter.
1331   7909 10 F9              djnz fopt0          ; repeat for relevant steps down the list.
1332   790B 3A 5E 84           ld a,(combyt)       ; get option.
1333   790E 3D                 dec a               ; one less, due to where we increment combyt.
1334   790F 32 55 77           ld (varopt),a       ; store the option.
1335   7912 C3 E7 79           jp redraw           ; redraw the screen.
1336   7915             
1337   7915 21 5E 84    fobj   ld hl,combyt        ; object number.
1338   7918 7E                 ld a,(hl)           ; get object number.
1339   7919 34                 inc (hl)            ; ready for next item.
1340   791A C8                 ret z               ; in case we loop back to zero.
1341   791B CD 49 81           call gotob          ; do we have this item?
1342   791E C8                 ret z               ; yes, it's on the list.
1343   791F 18 F4              jr fobj             ; repeat until we find next item in pockets.
1344   7921             
1345   7921 00          bwid   defb 0              ; box/menu width.
1346   7922 00          blen   defb 0              ; box/menu height.
1347   7923 00          btop   defb 0              ; box coordinates.
1348   7924 00          blft   defb 0
1349   7925             
1350   7925             ; Wait for keypress.
1351   7925             
1352   7925 CD 31 79    prskey call debkey         ; debounce key.
1353   7928 CD 7C 79    prsky0 call vsync          ; vertical synch.
1354   792B CD 8E 02           call 654            ; return keyboard state in e.
1355   792E 1C                 inc e               ; is it 255?
1356   792F 28 F7              jr z,prsky0         ; yes, repeat until key pressed.
1357   7931             
1358   7931             ; Debounce keypress.
1359   7931             
1360   7931 CD 7C 79    debkey call vsync          ; update scrolling, sounds etc.
1361   7934 CD 8E 02           call 654            ; d=shift, e=key.
1362   7937 1C                 inc e               ; is it 255?
1363   7938 20 F7              jr nz,debkey        ; no - loop until key is released.
1364   793A C9                 ret
1365   793B             
1366   793B             ; Delay routine.
1367   793B             
1368   793B C5          delay  push bc             ; store loop counter.
1369   793C CD 7C 79           call vsync          ; wait for interrupt.
1370   793F C1                 pop bc              ; restore counter.
1371   7940 10 F9              djnz delay          ; repeat.
1372   7942 C9                 ret
1373   7943             
1374   7943             ; Clear sprite table.
1375   7943             
1376   7943 21 65 8D    xspr   ld hl,sprtab        ; sprite table.
1377   7946 06 CC              ld b,SPRBUF         ; length of table.
1378   7948 36 FF       xspr0  ld (hl),255         ; clear one byte.
1379   794A 23                 inc hl              ; move to next byte.
1380   794B 10 FB              djnz xspr0          ; repeat for rest of table.
1381   794D C9                 ret
1382   794E             
1383   794E CD 36 80    silenc call silen1         ; silence channel 1.
1384   7951 CD 43 80           call silen2         ; silence channel 2.
1385   7954 CD 50 80           call silen3         ; silence channel 3.
1386   7957 C3 C0 8E           jp plsnd            ; play all channels to switch them off.
1387   795A             
1388   795A             ; Initialise all objects.
1389   795A             
1390   795A DD 21 4A 73 iniob  ld ix,objdta        ; objects table.
1391   795E 3A 30 77           ld a,(numob)        ; number of objects in the game.
1392   7961 47                 ld b,a              ; loop counter.
1393   7962 11 27 00           ld de,39            ; distance between objects.
1394   7965 DD 7E 24    iniob0 ld a,(ix+36)        ; start screen.
1395   7968 DD 77 21           ld (ix+33),a        ; set start screen.
1396   796B DD 7E 25           ld a,(ix+37)        ; find start x.
1397   796E DD 77 22           ld (ix+34),a        ; set start x.
1398   7971 DD 7E 26           ld a,(ix+38)        ; get initial y.
1399   7974 DD 77 23           ld (ix+35),a        ; set y coord.
1400   7977 DD 19              add ix,de           ; point to next object.
1401   7979 10 EA              djnz iniob0         ; repeat.
1402   797B C9                 ret
1403   797C             
1404   797C             ; Screen synchronisation.
1405   797C             
1406   797C CD 4F 86    vsync  call joykey         ; read joystick/keyboard.
1407   797F 3A E6 79           ld a,(sndtyp)       ; sound to play.
1408   7982 A7                 and a               ; any sound?
1409   7983 CA AD 79           jp z,vsync1         ; no.
1410   7986 47                 ld b,a              ; outer loop.
1411   7987 3A 48 5C           ld a,(23624)        ; border colour.
1412   798A 1F                 rra                 ; put border bits into d0, d1 and d2.
1413   798B 1F                 rra
1414   798C 1F                 rra
1415   798D 4F                 ld c,a              ; first value to write to speaker.
1416   798E 78                 ld a,b              ; sound.
1417   798F A7                 and a               ; test it.
1418   7990 FA C5 79           jp m,vsync6         ; play white noise.
1419   7993 79          vsync2 ld a,c              ; get speaker value.
1420   7994 D3 FE              out (254),a         ; write to speaker.
1421   7996 EE F8              xor 248             ; toggle all except the border bits.
1422   7998 4F                 ld c,a              ; store value for next time.
1423   7999 50                 ld d,b              ; store loop counter.
1424   799A 21 52 77    vsync3 ld hl,clock         ; previous clock setting.
1425   799D 3A 78 5C           ld a,(23672)        ; current clock setting.
1426   79A0 BE                 cp (hl)             ; subtract last reading.
1427   79A1 C2 A9 79           jp nz,vsync4        ; yes, no more processing please.
1428   79A4 10 F4              djnz vsync3         ; loop.
1429   79A6 42                 ld b,d              ; restore loop counter.
1430   79A7 10 EA              djnz vsync2         ; continue noise.
1431   79A9 7A          vsync4 ld a,d              ; where we got to.
1432   79AA 32 E6 79    vsynca ld (sndtyp),a       ; remember for next time.
1433   79AD 3A 78 5C    vsync1 ld a,(23672)        ; clock low.
1434   79B0 1F                 rra                 ; rotate bit into carry.
1435   79B1 DC BF 79           call c,vsync5       ; time to play sound and do shrapnel/ticker stuff.
1436   79B4 21 52 77           ld hl,clock         ; last clock reading.
1437   79B7 3A 78 5C    vsync0 ld a,(23672)        ; current clock reading.
1438   79BA BE                 cp (hl)             ; are they the same?
1439   79BB 28 FA              jr z,vsync0         ; yes, wait until clock changes.
1440   79BD 77                 ld (hl),a           ; set new clock reading.
1441   79BE C9                 ret
1442   79BF CD C0 8E    vsync5 call plsnd          ; play sound.
1443   79C2 C3 EF 7A           jp proshr           ; shrapnel and stuff.
1444   79C5             
1445   79C5             ; Play white noise.
1446   79C5             
1447   79C5 78          vsync6 ld a,b              ; 128 - 255.
1448   79C6 D6 7F              sub 127
1449   79C8 47                 ld b,a
1450   79C9 21 52 77           ld hl,clock         ; previous clock setting.
1451   79CC ED 5F       vsync7 ld a,r              ; get random speaker value.
1452   79CE E6 F8              and 248             ; only retain the speaker/earphone bits.
1453   79D0 B1                 or c                ; merge with border colour.
1454   79D1 D3 FE              out (254),a         ; write to speaker.
1455   79D3 3A 78 5C           ld a,(23672)        ; current clock setting.
1456   79D6 BE                 cp (hl)             ; subtract last reading.
1457   79D7 C2 E3 79           jp nz,vsync8        ; yes, no more processing please.
1458   79DA 78                 ld a,b
1459   79DB E6 7F              and 127
1460   79DD 3C                 inc a
1461   79DE 3D          vsync9 dec a
1462   79DF 20 FD              jr nz,vsync9        ; loop.
1463   79E1 10 E9              djnz vsync7         ; continue noise.
1464   79E3 AF          vsync8 xor a
1465   79E4 18 C4              jr vsynca
1466   79E6 00          sndtyp defb 0
1467   79E7             ;clock  defb 0              ; last clock reading.
1468   79E7             
1469   79E7             ; Redraw the screen.
1470   79E7             
1471   79E7             ; Remove old copy of all sprites for redraw.
1472   79E7             
1473   79E7 DD E5       redraw push ix             ; place sprite pointer on stack.
1474   79E9 CD 0B 84           call droom          ; show screen layout.
1475   79EC CD 97 80           call shwob          ; draw objects.
1476   79EF 06 0C       numsp0 ld b,NUMSPR         ; sprites to draw.
1477   79F1 DD 21 65 8D        ld ix,sprtab        ; sprite table.
1478   79F5 DD 7E 00    redrw0 ld a,(ix+0)         ; old sprite type.
1479   79F8 3C                 inc a               ; is it enabled?
1480   79F9 28 0C              jr z,redrw1         ; no, find next one.
1481   79FB DD 7E 03           ld a,(ix+3)         ; sprite x.
1482   79FE FE B1              cp 177              ; beyond maximum?
1483   7A00 30 05              jr nc,redrw1        ; yes, nothing to draw.
1484   7A02 C5                 push bc             ; store sprite counter.
1485   7A03 CD 11 89           call sspria         ; show single sprite.
1486   7A06 C1                 pop bc              ; retrieve sprite counter.
1487   7A07 11 11 00    redrw1 ld de,TABSIZ        ; distance to next odd/even entry.
1488   7A0A DD 19              add ix,de           ; next sprite.
1489   7A0C 10 E7              djnz redrw0         ; repeat for remaining sprites.
1490   7A0E CD C4 8E           call rbloc          ; redraw blocks if in adventure mode.
1491   7A11 CD 91 7D           call dshrp          ; redraw shrapnel.
1492   7A14 DD E1              pop ix              ; retrieve sprite pointer.
1493   7A16 C9                 ret
1494   7A17             
1495   7A17             ; Clear screen routine.
1496   7A17             
1497   7A17 21 00 40    cls    ld hl,16384         ; screen address.
1498   7A1A 75                 ld (hl),l           ; blank first byte.
1499   7A1B 11 01 40           ld de,16385         ; second byte.
1500   7A1E 01 00 18           ld bc,6144          ; bytes to copy.
1501   7A21 ED B0              ldir                ; blank them all.
1502   7A23 3A 8D 5C           ld a,(23693)        ; fetch attributes.
1503   7A26 77                 ld (hl),a           ; set first attribute cell.
1504   7A27 01 FF 02           ld bc,767           ; number of attributes.
1505   7A2A ED B0              ldir                ; set all attributes.
1506   7A2C 21 00 00           ld hl,0             ; set hl to origin (0, 0).
1507   7A2F 22 50 77           ld (charx),hl       ; reset coordinates.
1508   7A32 C9                 ret
1509   7A33             
1510   7A33             ; Set palette routine and data.
1511   7A33             ; Palette.
1512   7A33             ; 48955 = register select port.
1513   7A33             ; 65339 = data read/write port.
1514   7A33             
1515   7A33             ; 48955 = write to register:
1516   7A33             ; d0-d5 : select register sub-group.
1517   7A33             ; d6-d7 : select register group.
1518   7A33             ;         00 = sub-group determines entry in palette table.
1519   7A33             ;         64 = mode select, write d0 to 65339 to toggle mode on/off.
1520   7A33             
1521   7A33             ; 65339 = data read/write:
1522   7A33             ; d0-d1 : blue intensity (last bit duplicated so Bb is Bbb)
1523   7A33             ; d2-d4 : red intensity
1524   7A33             ; d5-d7 : green intensity
1525   7A33             
1526   7A33 01 3B BF    setpal ld bc,48955         ; register select.
1527   7A36 3E 40              ld a,64             ; mode select.
1528   7A38 ED 79              out (c),a           ; set ULAplus mode.
1529   7A3A 06 FF              ld b,255            ; data write.
1530   7A3C 3E 01              ld a,1              ; mode on.
1531   7A3E ED 79              out (c),a           ; switch on ULAplus.
1532   7A40             
1533   7A40 06 40              ld b,64             ; number of palette table entries to write.
1534   7A42 21 71 73    setpa1 ld hl,palett        ; palette we want.
1535   7A45 1E 00              ld e,0              ; register number.
1536   7A47 C5          setpa0 push bc             ; store counter.
1537   7A48 06 BF              ld b,191            ; register select.
1538   7A4A 7B                 ld a,e              ; register number to write.
1539   7A4B ED 79              out (c),a           ; write to port.
1540   7A4D 06 FF              ld b,255            ; data select.
1541   7A4F 7E                 ld a,(hl)           ; get colour data from table.
1542   7A50 ED 79              out (c),a           ; write to port.
1543   7A52 1C                 inc e               ; next clut entry.
1544   7A53 23                 inc hl              ; next table entry.
1545   7A54 C1                 pop bc              ; restore counter from stack.
1546   7A55 10 F0              djnz setpa0         ; set rest of palette.
1547   7A57 C9                 ret
1548   7A58             
1549   7A58             endpal equ $
1550   7A58             
1551   7A58 7E          fdchk  ld a,(hl)           ; fetch cell.
1552   7A59 FE 04              cp FODDER           ; is it fodder?
1553   7A5B C0                 ret nz              ; no.
1554   7A5C 36 00              ld (hl),0           ; rewrite block type.
1555   7A5E E5                 push hl             ; store pointer to block.
1556   7A5F 11 00 FD           ld de,MAP           ; address of map.
1557   7A62 A7                 and a               ; clear carry flag for subtraction.
1558   7A63 ED 52              sbc hl,de           ; find simple displacement for block.
1559   7A65 7D                 ld a,l              ; low byte is y coordinate.
1560   7A66 E6 1F              and 31              ; column position 0 - 31.
1561   7A68 32 5C 77           ld (dispy),a        ; set up y position.
1562   7A6B 29                 add hl,hl           ; multiply displacement by 8.
1563   7A6C 29                 add hl,hl
1564   7A6D 29                 add hl,hl
1565   7A6E 7C                 ld a,h              ; x coordinate now in h.
1566   7A6F 32 5B 77           ld (dispx),a        ; set the display coordinate.
1567   7A72 2A 5F 77           ld hl,(blkptr)      ; blocks.
1568   7A75 22 2E 82           ld (grbase),hl      ; set graphics base.
1569   7A78 AF                 xor a               ; block to write.
1570   7A79 CD 58 83           call pattr          ; write block.
1571   7A7C E1                 pop hl              ; restore block pointer.
1572   7A7D C9                 ret
1573   7A7E             
1574   7A7E             ; Colour a sprite.
1575   7A7E             
1576   7A7E             cspr   equ $
1577   7A7E DD 7E 08           ld a,(ix+8)         ; look at the vertical first.
1578   7A81 FE B1              cp 177              ; is it out-of-range?
1579   7A83 D0                 ret nc              ; yes, can't colour it.
1580   7A84 07                 rlca                ; divide by 64.
1581   7A85 07                 rlca                ; quicker than 6 rrca operations.
1582   7A86 6F                 ld l,a              ; store in e register for now.
1583   7A87 E6 03              and 3               ; mask to find segment.
1584   7A89 C6 58              add a,88            ; attributes start at 88*256=22528.
1585   7A8B 67                 ld h,a              ; that's our high byte sorted.
1586   7A8C 7D                 ld a,l              ; vertical/64 - same as vertical*4.
1587   7A8D E6 E0              and 224             ; want a multiple of 32.
1588   7A8F 6F                 ld l,a              ; vertical element calculated.
1589   7A90 DD 7E 09           ld a,(ix+9)         ; get horizontal position.
1590   7A93 1F                 rra                 ; divide by 8.
1591   7A94 1F                 rra
1592   7A95 1F                 rra
1593   7A96 E6 1F              and 31              ; want result in range 0-31.
1594   7A98 85                 add a,l             ; add to existing low byte.
1595   7A99 6F                 ld l,a              ; that's the low byte done.
1596   7A9A 11 1E 00           ld de,30            ; distance to next line down.
1597   7A9D E5                 push hl             ; store address of attributes on stack.
1598   7A9E D9                 exx                 ; put attributes in alternate bank.
1599   7A9F E1                 pop hl              ; retrieve attributes address.
1600   7AA0 11 00 A5           ld de,MAP-22528     ; distance to properties.
1601   7AA3 19                 add hl,de           ; address of first block property.
1602   7AA4             
1603   7AA4 11 1E 00           ld de,30            ; distance to next line down.
1604   7AA7 DD 7E 08           ld a,(ix+8)         ; x coordinate.
1605   7AAA 06 03       cspr2  ld b,3              ; default rows to write.
1606   7AAC E6 07              and 7               ; does x straddle cells?
1607   7AAE 20 01              jr nz,cspr0         ; yes, loop counter is good.
1608   7AB0 05                 dec b               ; one fewer rows to write.
1609   7AB1 7E          cspr0  ld a,(hl)           ; get property.
1610   7AB2 A7                 and a               ; is it empty space?
1611   7AB3 20 07              jr nz,cspr6         ; yes, don't paint it.
1612   7AB5 D9                 exx                 ; switch to attributes.
1613   7AB6 7E                 ld a,(hl)           ; get attribute.
1614   7AB7 E6 F8              and SIMASK          ; remove ink.
1615   7AB9 B1                 or c                ; put in the new ink.
1616   7ABA 77                 ld (hl),a           ; write back again.
1617   7ABB D9                 exx                 ; switch to properties.
1618   7ABC 2C          cspr6  inc l               ; next cell.
1619   7ABD D9                 exx                 ; switch to attributes.
1620   7ABE 2C                 inc l               ; next cell.
1621   7ABF D9                 exx                 ; switch to properties.
1622   7AC0 7E                 ld a,(hl)           ; fetch block property.
1623   7AC1 A7                 and a               ; is it empty space?
1624   7AC2 20 07              jr nz,cspr7         ; yes, don't paint it.
1625   7AC4 D9                 exx                 ; switch to attributes.
1626   7AC5 7E                 ld a,(hl)           ; get attributes.
1627   7AC6 E6 F8              and SIMASK          ; remove ink.
1628   7AC8 B1                 or c                ; put in the new ink.
1629   7AC9 77                 ld (hl),a           ; write back again.
1630   7ACA D9                 exx                 ; switch to properties.
1631   7ACB 2C          cspr7  inc l               ; next cell.
1632   7ACC D9                 exx                 ; switch to attributes.
1633   7ACD 2C                 inc l               ; next cell.
1634   7ACE D9                 exx                 ; switch to properties.
1635   7ACF DD 7E 09           ld a,(ix+9)         ; y coordinate.
1636   7AD2 E6 07              and 7               ; straddling cells?
1637   7AD4 28 0A              jr z,cspr1          ; no, only 2 wide.
1638   7AD6 7E                 ld a,(hl)           ; get attributes.
1639   7AD7 A7                 and a               ; is it empty space?
1640   7AD8 20 06              jr nz,cspr1         ; yes, don't paint it.
1641   7ADA D9                 exx                 ; switch to attributes.
1642   7ADB E6 F8              and SIMASK          ; remove ink.
1643   7ADD B1                 or c                ; put in the new ink.
1644   7ADE 77                 ld (hl),a           ; write back again.
1645   7ADF D9                 exx                 ; switch to properties.
1646   7AE0 19          cspr1  add hl,de           ; next row.
1647   7AE1 D9                 exx                 ; switch to attributes.
1648   7AE2 19                 add hl,de           ; next row.
1649   7AE3 D9                 exx                 ; switch to properties.
1650   7AE4 10 CB              djnz cspr0
1651   7AE6 C9                 ret
1652   7AE7             
1653   7AE7             ; Scrolly text and puzzle variables.
1654   7AE7             
1655   7AE7 80          txtbit defb 128            ; bit to write.
1656   7AE8 10          txtwid defb 16             ; width of ticker message.
1657   7AE9 91 66       txtpos defw msgdat
1658   7AEB 91 66       txtini defw msgdat
1659   7AED 16 40       txtscr defw 16406
1660   7AEF             
1661   7AEF             ; Specialist routines.
1662   7AEF             ; Process shrapnel.
1663   7AEF             
1664   7AEF DD 21 B6 F9 proshr ld ix,SHRAPN        ; table.
1665   7AF3 06 37              ld b,NUMSHR         ; shrapnel pieces to process.
1666   7AF5 11 06 00           ld de,SHRSIZ        ; distance to next.
1667   7AF8 DD 7E 00    prosh0 ld a,(ix+0)         ; on/off marker.
1668   7AFB 17                 rla                 ; check its status.
1669   7AFC D4 06 7B    proshx call nc,prosh1      ; on, so process it.
1670   7AFF DD 19              add ix,de           ; point there.
1671   7B01 10 F5              djnz prosh0         ; round again.
1672   7B03 C3 DA 8C           jp scrly
1673   7B06 C5          prosh1 push bc             ; store counter.
1674   7B07 CD 90 7B           call plot           ; delete the pixel.
1675   7B0A DD 7E 00           ld a,(ix+0)         ; restore shrapnel type.
1676   7B0D 21 23 7B           ld hl,shrptr        ; shrapnel routine pointers.
1677   7B10 CD 1B 7B           call prosh2         ; run the routine.
1678   7B13 CD 6E 7B           call chkxy          ; check x and y are good before we redisplay.
1679   7B16 C1                 pop bc              ; restore counter.
1680   7B17 11 06 00           ld de,SHRSIZ        ; distance to next.
1681   7B1A C9                 ret
1682   7B1B 07          prosh2 rlca                ; 2 bytes per address.
1683   7B1C 5F                 ld e,a              ; copy to de.
1684   7B1D 19                 add hl,de           ; point to address of routine.
1685   7B1E 7E                 ld a,(hl)           ; get address low.
1686   7B1F 23                 inc hl              ; point to second byte.
1687   7B20 66                 ld h,(hl)           ; fetch high byte from table.
1688   7B21 6F                 ld l,a              ; put low byte in l.
1689   7B22 E9                 jp (hl)             ; jump to routine.
1690   7B23             
1691   7B23 24 7C       shrptr defw laser          ; laser.
1692   7B25 FD 7B              defw trail          ; vapour trail.
1693   7B27 33 7B              defw shrap          ; shrapnel from explosion.
1694   7B29 5E 7B              defw dotl           ; horizontal starfield left.
1695   7B2B 62 7B              defw dotr           ; horizontal starfield right.
1696   7B2D 66 7B              defw dotu           ; vertical starfield up.
1697   7B2F 6A 7B              defw dotd           ; vertical starfield down.
1698   7B31 90 66              defw ptcusr         ; user particle.
1699   7B33             
1700   7B33             ; Explosion shrapnel.
1701   7B33             
1702   7B33 DD 5E 01    shrap  ld e,(ix+1)         ; get the angle.
1703   7B36 16 00              ld d,0              ; no high byte.
1704   7B38 21 BD 7B           ld hl,shrsin        ; shrapnel sine table.
1705   7B3B 19                 add hl,de           ; point to sine.
1706   7B3C             
1707   7B3C 5E                 ld e,(hl)           ; fetch value from table.
1708   7B3D 23                 inc hl              ; next byte of table.
1709   7B3E 56                 ld d,(hl)           ; fetch value from table.
1710   7B3F 23                 inc hl              ; next byte of table.
1711   7B40 4E                 ld c,(hl)           ; fetch value from table.
1712   7B41 23                 inc hl              ; next byte of table.
1713   7B42 46                 ld b,(hl)           ; fetch value from table.
1714   7B43 DD 6E 02           ld l,(ix+2)         ; x coordinate in hl.
1715   7B46 DD 66 03           ld h,(ix+3)
1716   7B49 19                 add hl,de           ; add sine.
1717   7B4A DD 75 02           ld (ix+2),l         ; store new coordinate.
1718   7B4D DD 74 03           ld (ix+3),h
1719   7B50 DD 6E 04           ld l,(ix+4)         ; y coordinate in hl.
1720   7B53 DD 66 05           ld h,(ix+5)
1721   7B56 09                 add hl,bc           ; add cosine.
1722   7B57 DD 75 04           ld (ix+4),l         ; store new coordinate.
1723   7B5A DD 74 05           ld (ix+5),h
1724   7B5D C9                 ret
1725   7B5E             
1726   7B5E DD 35 05    dotl   dec (ix+5)          ; move left.
1727   7B61 C9                 ret
1728   7B62 DD 34 05    dotr   inc (ix+5)          ; move left.
1729   7B65 C9                 ret
1730   7B66 DD 35 03    dotu   dec (ix+3)          ; move up.
1731   7B69 C9                 ret
1732   7B6A DD 34 03    dotd   inc (ix+3)          ; move down.
1733   7B6D C9                 ret
1734   7B6E             
1735   7B6E             ; Check coordinates are good before redrawing at new position.
1736   7B6E             
1737   7B6E 21 31 77    chkxy  ld hl,wntopx        ; window top.
1738   7B71 DD 7E 03           ld a,(ix+3)         ; fetch shrapnel coordinate.
1739   7B74 BE                 cp (hl)             ; compare with top window limit.
1740   7B75 38 41              jr c,kilshr         ; out of window, kill shrapnel.
1741   7B77 23                 inc hl              ; left edge.
1742   7B78 DD 7E 05           ld a,(ix+5)         ; fetch shrapnel coordinate.
1743   7B7B BE                 cp (hl)             ; compare with left window limit.
1744   7B7C 38 3A              jr c,kilshr         ; out of window, kill shrapnel.
1745   7B7E             
1746   7B7E 23                 inc hl              ; point to bottom.
1747   7B7F 7E                 ld a,(hl)           ; fetch window limit.
1748   7B80 C6 0F              add a,15            ; add height of sprite.
1749   7B82 DD BE 03           cp (ix+3)           ; compare with shrapnel x coordinate.
1750   7B85 38 31              jr c,kilshr         ; off screen, kill shrapnel.
1751   7B87 23                 inc hl              ; point to right edge.
1752   7B88 7E                 ld a,(hl)           ; fetch shrapnel y coordinate.
1753   7B89 C6 0F              add a,15            ; add width of sprite.
1754   7B8B DD BE 05           cp (ix+5)           ; compare with window limit.
1755   7B8E 38 28              jr c,kilshr         ; off screen, kill shrapnel.
1756   7B90             
1757   7B90             ; Drop through.
1758   7B90             ; Display shrapnel.
1759   7B90             
1760   7B90 DD 6E 03    plot   ld l,(ix+3)         ; x integer.
1761   7B93 DD 66 05           ld h,(ix+5)         ; y integer.
1762   7B96 22 5B 77           ld (dispx),hl       ; workspace coordinates.
1763   7B99 DD 7E 00           ld a,(ix+0)         ; type.
1764   7B9C A7                 and a               ; is it a laser?
1765   7B9D 28 12              jr z,plot1          ; yes, draw laser instead.
1766   7B9F 7C          plot0  ld a,h              ; which pixel within byte do we
1767   7BA0 E6 07              and 7               ; want to set first?
1768   7BA2 16 00              ld d,0              ; no high byte.
1769   7BA4 5F                 ld e,a              ; copy to de.
1770   7BA5 21 4F 7C           ld hl,dots          ; table of small pixel positions.
1771   7BA8 19                 add hl,de           ; hl points to values we want to POKE to screen.
1772   7BA9 5E                 ld e,(hl)           ; get value.
1773   7BAA CD F4 88           call scadd          ; screen address.
1774   7BAD 7E                 ld a,(hl)           ; see what's already there.
1775   7BAE AB                 xor e               ; merge with pixels.
1776   7BAF 77                 ld (hl),a           ; put back on screen.
1777   7BB0 C9                 ret
1778   7BB1 CD F4 88    plot1  call scadd          ; screen address.
1779   7BB4 7E                 ld a,(hl)           ; fetch byte there.
1780   7BB5 2F                 cpl                 ; toggle all bits.
1781   7BB6 77                 ld (hl),a           ; new byte.
1782   7BB7 C9                 ret
1783   7BB8             
1784   7BB8 DD 36 00 80 kilshr ld (ix+0),128       ; switch off shrapnel.
1785   7BBC C9                 ret
1786   7BBD             
1787   7BBD             ;explc  defb 0              ; explosion counter.
1788   7BBD             
1789   7BBD             shrsin defw 0,1024,391,946,724,724,946,391
1789   7BBD 000000048701B203D402D402B2038701
1790   7BCD                    defw 1024,0,946,65144,724,64811,391,64589
1790   7BCD 00040000B20378FED4022BFD87014DFC
1791   7BDD                    defw 0,64512,65144,64589,64811,64811,64589,65144
1791   7BDD 000000FC78FE4DFC2BFD2BFD4DFC78FE
1792   7BED                    defw 64512,0,64589,391,64811,724,65144,946
1792   7BED 00FC00004DFC87012BFDD40278FEB203
1793   7BFD             
1794   7BFD DD 35 01    trail  dec (ix+1)          ; time remaining.
1795   7C00 CA 1F 7C           jp z,trailk         ; time to switch it off.
1796   7C03 CD 83 7D           call qrand          ; get a random number.
1797   7C06 1F                 rra                 ; x or y axis?
1798   7C07 38 0B              jr c,trailv         ; use x.
1799   7C09 1F                 rra                 ; which direction?
1800   7C0A 38 04              jr c,traill         ; go left.
1801   7C0C DD 34 05           inc (ix+5)          ; go right.
1802   7C0F C9                 ret
1803   7C10 DD 35 05    traill dec (ix+5)          ; go left.
1804   7C13 C9                 ret
1805   7C14 1F          trailv rra                 ; which direction?
1806   7C15 38 04              jr c,trailu         ; go up.
1807   7C17 DD 34 03           inc (ix+3)          ; go down.
1808   7C1A C9                 ret
1809   7C1B DD 35 03    trailu dec (ix+3)          ; go up.
1810   7C1E C9                 ret
1811   7C1F DD 36 03 C8 trailk ld (ix+3),200       ; set off-screen to kill vapour trail.
1812   7C23 C9                 ret
1813   7C24             
1814   7C24 DD 7E 01    laser  ld a,(ix+1)         ; direction.
1815   7C27 1F                 rra                 ; left or right?
1816   7C28 30 04              jr nc,laserl        ; move left.
1817   7C2A 06 08              ld b,8              ; distance to travel.
1818   7C2C 18 02              jr laserm           ; move laser.
1819   7C2E 06 F8       laserl ld b,248            ; distance to travel.
1820   7C30 DD 7E 05    laserm ld a,(ix+5)         ; y position.
1821   7C33 80                 add a,b             ; add distance.
1822   7C34 DD 77 05           ld (ix+5),a         ; set new y coordinate.
1823   7C37             
1824   7C37             ; Test new block.
1825   7C37             
1826   7C37 32 5C 77           ld (dispy),a        ; set y for block collision detection purposes.
1827   7C3A DD 7E 03           ld a,(ix+3)         ; get x.
1828   7C3D 32 5B 77           ld (dispx),a        ; set coordinate for collision test.
1829   7C40 CD E7 85           call tstbl          ; get block type there.
1830   7C43 FE 02              cp WALL             ; is it solid?
1831   7C45 28 D8              jr z,trailk         ; yes, it cannot pass.
1832   7C47 FE 04              cp FODDER           ; is it fodder?
1833   7C49 C0                 ret nz              ; no, ignore it.
1834   7C4A CD 58 7A           call fdchk          ; remove fodder block.
1835   7C4D 18 D0              jr trailk           ; destroy laser.
1836   7C4F             
1837   7C4F             dots   defb 128,64,32,16,8,4,2,1
1837   7C4F 8040201008040201
1838   7C57             
1839   7C57             ; Plot, preserving de.
1840   7C57             
1841   7C57 D5          plotde push de             ; put de on stack.
1842   7C58 CD 90 7B           call plot           ; plot pixel.
1843   7C5B D1                 pop de              ; restore de from stack.
1844   7C5C C9                 ret
1845   7C5D             
1846   7C5D             ; Shoot a laser.
1847   7C5D             
1848   7C5D 4F          shoot  ld c,a              ; store direction in c register.
1849   7C5E DD 7E 08           ld a,(ix+8)         ; x coordinate.
1850   7C61 C6 07       shoot1 add a,7             ; down 7 pixels.
1851   7C63 6F                 ld l,a              ; puty x coordinate in l.
1852   7C64 DD 66 09           ld h,(ix+9)         ; y coordinate in h.
1853   7C67 DD E5              push ix             ; store pointer to sprite.
1854   7C69 CD 2B 7D           call fpslot         ; find particle slot.
1855   7C6C 30 2C              jr nc,vapou2        ; failed, restore ix.
1856   7C6E DD 36 00 00        ld (ix+0),0         ; set up a laser.
1857   7C72 DD 71 01           ld (ix+1),c         ; set the direction.
1858   7C75 DD 75 03           ld (ix+3),l         ; set x coordinate.
1859   7C78 CB 19              rr c                ; check direction we want.
1860   7C7A 38 08              jr c,shootr         ; shoot right.
1861   7C7C 7C                 ld a,h              ; y position.
1862   7C7D             ;       dec a               ; left a pixel.
1863   7C7D E6 F8       shoot0 and 248             ; align on character boundary.
1864   7C7F DD 77 05           ld (ix+5),a         ; set y coordinate.
1865   7C82 18 2D              jr vapou0           ; draw first image.
1866   7C84 7C          shootr ld a,h              ; y position.
1867   7C85 C6 0F              add a,15            ; look right.
1868   7C87 18 F4              jr shoot0           ; align and continue.
1869   7C89             
1870   7C89             ; Create a bit of vapour trail.
1871   7C89             
1872   7C89 DD E5       vapour push ix             ; store pointer to sprite.
1873   7C8B DD 6E 08           ld l,(ix+8)         ; x coordinate.
1874   7C8E DD 66 09           ld h,(ix+9)         ; y coordinate.
1875   7C91 11 07 07    vapou3 ld de,7*256+7       ; mid-point of sprite.
1876   7C94 19                 add hl,de           ; point to centre of sprite.
1877   7C95 CD 2B 7D           call fpslot         ; find particle slot.
1878   7C98 38 03              jr c,vapou1         ; no, we can use it.
1879   7C9A DD E1       vapou2 pop ix              ; restore sprite pointer.
1880   7C9C C9                 ret                 ; out of slots, can't generate anything.
1881   7C9D             
1882   7C9D DD 75 03    vapou1 ld (ix+3),l         ; set up x.
1883   7CA0 DD 74 05           ld (ix+5),h         ; set up y coordinate.
1884   7CA3 CD 83 7D           call qrand          ; get quick random number.
1885   7CA6 E6 0F              and 15              ; random time.
1886   7CA8 C6 0F              add a,15            ; minimum time on screen.
1887   7CAA DD 77 01           ld (ix+1),a         ; set time on screen.
1888   7CAD DD 36 00 01        ld (ix+0),1         ; define particle as vapour trail.
1889   7CB1 CD 6E 7B    vapou0 call chkxy          ; plot first position.
1890   7CB4 18 E4              jr vapou2
1891   7CB6             
1892   7CB6             ; Create a user particle.
1893   7CB6             
1894   7CB6 08          ptusr  ex af,af'           ; store timer.
1895   7CB7 DD 6E 08           ld l,(ix+8)         ; x coordinate.
1896   7CBA DD 66 09           ld h,(ix+9)         ; y coordinate.
1897   7CBD 11 07 07           ld de,7*256+7       ; mid-point of sprite.
1898   7CC0 19                 add hl,de           ; point to centre of sprite.
1899   7CC1 CD 2B 7D           call fpslot         ; find particle slot.
1900   7CC4 38 01              jr c,ptusr1         ; no, we can use it.
1901   7CC6 C9                 ret                 ; out of slots, can't generate anything.
1902   7CC7             
1903   7CC7 DD 75 03    ptusr1 ld (ix+3),l         ; set up x.
1904   7CCA DD 74 05           ld (ix+5),h         ; set up y coordinate.
1905   7CCD 08                 ex af,af'           ; restore timer.
1906   7CCE DD 77 01           ld (ix+1),a         ; set time on screen.
1907   7CD1 DD 36 00 07        ld (ix+0),7         ; define particle as user particle.
1908   7CD5 C3 6E 7B           jp chkxy            ; plot first position.
1909   7CD8             
1910   7CD8             
1911   7CD8             ; Create a vertical or horizontal star.
1912   7CD8             
1913   7CD8 DD E5       star   push ix             ; store pointer to sprite.
1914   7CDA CD 2B 7D           call fpslot         ; find particle slot.
1915   7CDD DA E3 7C           jp c,star7          ; found one we can use.
1916   7CE0 DD E1       star0  pop ix              ; restore sprite pointer.
1917   7CE2 C9                 ret                 ; out of slots, can't generate anything.
1918   7CE3             
1919   7CE3 79          star7  ld a,c              ; direction.
1920   7CE4 E6 03              and 3               ; is it left?
1921   7CE6 28 21              jr z,star1          ; yes, it's horizontal.
1922   7CE8 3D                 dec a               ; is it right?
1923   7CE9 28 2C              jr z,star2          ; yes, it's horizontal.
1924   7CEB 3D                 dec a               ; is it up?
1925   7CEC 28 35              jr z,star3          ; yes, it's vertical.
1926   7CEE             
1927   7CEE 3A 31 77           ld a,(wntopx)       ; get edge of screen.
1928   7CF1 3C                 inc a               ; down one pixel.
1929   7CF2 DD 77 03    star8  ld (ix+3),a         ; set x coord.
1930   7CF5 CD 83 7D           call qrand          ; get quick random number.
1931   7CF8 DD 77 05    star9  ld (ix+5),a         ; set y position.
1932   7CFB 79                 ld a,c              ; direction.
1933   7CFC E6 03              and 3               ; zero to three.
1934   7CFE C6 03              add a,3             ; 3 to 6 for starfield.
1935   7D00 DD 77 00           ld (ix+0),a         ; define particle as star.
1936   7D03 CD 6E 7B           call chkxy          ; plot first position.
1937   7D06 C3 E0 7C           jp star0
1938   7D09 CD 83 7D    star1  call qrand          ; get quick random number.
1939   7D0C DD 77 03           ld (ix+3),a         ; set x coord.
1940   7D0F 3A 34 77           ld a,(wnrgtx)       ; get edge of screen.
1941   7D12 C6 0F              add a,15            ; add width of sprite minus 1.
1942   7D14 C3 F8 7C           jp star9
1943   7D17 CD 83 7D    star2  call qrand          ; get quick random number.
1944   7D1A DD 77 03           ld (ix+3),a         ; set x coord.
1945   7D1D 3A 32 77           ld a,(wnlftx)       ; get edge of screen.
1946   7D20 C3 F8 7C           jp star9
1947   7D23 3A 33 77    star3  ld a,(wnbotx)       ; get edge of screen.
1948   7D26 C6 0F              add a,15            ; height of sprite minus one pixel.
1949   7D28 C3 F2 7C           jp star8
1950   7D2B             
1951   7D2B             
1952   7D2B             ; Find particle slot for lasers or vapour trail.
1953   7D2B             ; Can't use alternate accumulator.
1954   7D2B             
1955   7D2B DD 21 B6 F9 fpslot ld ix,SHRAPN        ; shrapnel table.
1956   7D2F 11 06 00           ld de,SHRSIZ        ; size of each particle.
1957   7D32 06 37              ld b,NUMSHR         ; number of pieces in table.
1958   7D34 DD 7E 00    fpslt0 ld a,(ix+0)         ; get type.
1959   7D37 17                 rla                 ; is this slot in use?
1960   7D38 D8                 ret c               ; no, we can use it.
1961   7D39 DD 19              add ix,de           ; point to more shrapnel.
1962   7D3B 10 F7              djnz fpslt0         ; repeat for all shrapnel.
1963   7D3D C9                 ret                 ; out of slots, can't generate anything.
1964   7D3E             
1965   7D3E             ; Create an explosion at sprite position.
1966   7D3E             
1967   7D3E 4F          explod ld c,a              ; particles to create.
1968   7D3F DD E5              push ix             ; store pointer to sprite.
1969   7D41 DD 6E 08           ld l,(ix+8)         ; x coordinate.
1970   7D44 DD 66 09           ld h,(ix+9)         ; y coordinate.
1971   7D47 DD 21 B6 F9        ld ix,SHRAPN        ; shrapnel table.
1972   7D4B 11 06 00           ld de,SHRSIZ        ; size of each particle.
1973   7D4E 06 37              ld b,NUMSHR         ; number of pieces in table.
1974   7D50 DD 7E 00    expld0 ld a,(ix+0)         ; get type.
1975   7D53 17                 rla                 ; is this slot in use?
1976   7D54 38 07              jr c,expld1         ; no, we can use it.
1977   7D56 DD 19       expld2 add ix,de           ; point to more shrapnel.
1978   7D58 10 F6              djnz expld0         ; repeat for all shrapnel.
1979   7D5A DD E1       expld3 pop ix              ; restore sprite pointer.
1980   7D5C C9                 ret                 ; out of slots, can't generate any more.
1981   7D5D 79          expld1 ld a,c              ; shrapnel counter.
1982   7D5E E6 0F              and 15              ; 0 to 15.
1983   7D60 85                 add a,l             ; add to x.
1984   7D61 DD 77 03           ld (ix+3),a         ; x coord.
1985   7D64 3A 90 7D           ld a,(seed3)        ; crap random number.
1986   7D67 E6 0F              and 15              ; 0 to 15.
1987   7D69 84                 add a,h             ; add to y.
1988   7D6A DD 77 05           ld (ix+5),a         ; y coord.
1989   7D6D DD 36 00 02        ld (ix+0),2         ; switch it on.
1990   7D71 D9                 exx                 ; store coordinates.
1991   7D72 CD 6E 7B           call chkxy          ; plot first position.
1992   7D75 CD 83 7D           call qrand          ; quick random angle.
1993   7D78 E6 3C              and 60              ; keep within range.
1994   7D7A DD 77 01           ld (ix+1),a         ; angle.
1995   7D7D D9                 exx                 ; restore coordinates.
1996   7D7E 0D                 dec c               ; one less piece of shrapnel to generate.
1997   7D7F 20 D5              jr nz,expld2        ; back to main explosion loop.
1998   7D81 18 D7              jr expld3           ; restore sprite pointer and exit.
1999   7D83 3A 90 7D    qrand  ld a,(seed3)        ; random seed.
2000   7D86 6F                 ld l,a              ; low byte.
2001   7D87 26 00              ld h,0              ; no high byte.
2002   7D89 ED 5F              ld a,r              ; r register.
2003   7D8B AE                 xor (hl)            ; combine with seed.
2004   7D8C 32 90 7D           ld (seed3),a        ; new seed.
2005   7D8F C9                 ret
2006   7D90 00          seed3  defb 0
2007   7D91             
2008   7D91             ; Display all shrapnel.
2009   7D91             
2010   7D91 21 57 7C    dshrp  ld hl,plotde        ; display routine.
2011   7D94 22 FD 7A           ld (proshx+1),hl    ; modify routine.
2012   7D97 CD EF 7A           call proshr         ; process shrapnel.
2013   7D9A 21 06 7B           ld hl,prosh1        ; processing routine.
2014   7D9D 22 FD 7A           ld (proshx+1),hl    ; modify the call.
2015   7DA0 C9                 ret
2016   7DA1             
2017   7DA1             ; Particle engine.
2018   7DA1             
2019   7DA1 21 B6 F9    inishr ld hl,SHRAPN        ; table.
2020   7DA4 06 37              ld b,NUMSHR         ; shrapnel pieces to process.
2021   7DA6 11 06 00           ld de,SHRSIZ        ; distance to next.
2022   7DA9 36 FF       inish0 ld (hl),255         ; kill the shrapnel.
2023   7DAB 19                 add hl,de           ; point there.
2024   7DAC 10 FB              djnz inish0         ; round again.
2025   7DAE C9                 ret
2026   7DAF             
2027   7DAF             ; Check for collision between laser and sprite.
2028   7DAF             
2029   7DAF 21 B6 F9    lcol   ld hl,SHRAPN        ; shrapnel table.
2030   7DB2 11 06 00           ld de,SHRSIZ        ; size of each particle.
2031   7DB5 06 37              ld b,NUMSHR         ; number of pieces in table.
2032   7DB7 7E          lcol0  ld a,(hl)           ; get type.
2033   7DB8 A7                 and a               ; is this slot a laser?
2034   7DB9 28 04              jr z,lcol1          ; yes, check collision.
2035   7DBB 19          lcol3  add hl,de           ; point to more shrapnel.
2036   7DBC 10 F9              djnz lcol0          ; repeat for all shrapnel.
2037   7DBE C9                 ret                 ; no collision, carry not set.
2038   7DBF E5          lcol1  push hl             ; store pointer to laser.
2039   7DC0 23                 inc hl              ; direction.
2040   7DC1 23                 inc hl              ; not used.
2041   7DC2 23                 inc hl              ; x position.
2042   7DC3 7E                 ld a,(hl)           ; get x.
2043   7DC4 DD 96 08           sub (ix+X)          ; subtract sprite x.
2044   7DC7 FE 10       lcolh  cp 16               ; within range?
2045   7DC9 30 0A              jr nc,lcol2         ; no, missed.
2046   7DCB 23                 inc hl              ; not used.
2047   7DCC 23                 inc hl              ; y position.
2048   7DCD 7E                 ld a,(hl)           ; get y.
2049   7DCE DD 96 09           sub (ix+Y)          ; subtract sprite y.
2050   7DD1 FE 10              cp 16               ; within range?
2051   7DD3 38 03              jr c,lcol4          ; yes, collision occurred.
2052   7DD5 E1          lcol2  pop hl              ; restore laser pointer from stack.
2053   7DD6 18 E3              jr lcol3
2054   7DD8 E1          lcol4  pop hl              ; restore laser pointer.
2055   7DD9 C9                 ret                 ; return with carry set for collision.
2056   7DDA             
2057   7DDA             ; Main game engine code starts here.
2058   7DDA             
2059   7DDA CD DF 7D    gamelp call game
2060   7DDD 18 FB              jr gamelp
2061   7DDF             
2062   7DDF             game   equ $
2063   7DDF             
2064   7DDF             ; Set up screen address table.
2065   7DDF             
2066   7DDF 21 00 40    setsat ld hl,16384         ; start of screen.
2067   7DE2 11 00 FB           ld de,SCADTB        ; screen address table.
2068   7DE5 06 00              ld b,0              ; vertical lines on screen.
2069   7DE7 EB          setsa0 ex de,hl            ; flip table and screen address.
2070   7DE8 72                 ld (hl),d           ; write high byte.
2071   7DE9 24                 inc h               ; second table.
2072   7DEA 73                 ld (hl),e           ; write low byte.
2073   7DEB 25                 dec h               ; back to first table.
2074   7DEC 2C                 inc l               ; next position in table.
2075   7DED EB                 ex de,hl            ; flip table and screen address back again.
2076   7DEE CD BA 89           call nline          ; next line down.
2077   7DF1 10 F4              djnz setsa0         ; repeat for all lines.
2078   7DF3             
2079   7DF3 CD 33 7A           call setpal         ; set up ULAplus palette.
2080   7DF6 CD A1 7D    rpblc2 call inishr         ; initialise particle engine.
2081   7DF9 CD 60 64    evintr call evnt12         ; call intro/menu event.
2082   7DFC             
2083   7DFC 21 00 FD           ld hl,MAP           ; block properties.
2084   7DFF 11 01 FD           ld de,MAP+1         ; next byte.
2085   7E02 01 FF 02           ld bc,767           ; size of property map.
2086   7E05 36 02              ld (hl),WALL        ; write default property.
2087   7E07 ED B0              ldir
2088   7E09 CD 5A 79           call iniob          ; initialise objects.
2089   7E0C AF                 xor a               ; put zero in accumulator.
2090   7E0D 32 5A 77           ld (gamwon),a       ; reset game won flag.
2091   7E10             
2092   7E10 21 1C 82           ld hl,score         ; score.
2093   7E13 CD 47 7F           call inisc          ; init the score.
2094   7E16 3A 12 61    mapst  ld a,(stmap)        ; start position on map.
2095   7E19 32 42 8E           ld (roomtb),a       ; set up position in table, if there is one.
2096   7E1C CD C1 8E    inipbl call ibloc          ; set up first screen.
2097   7E1F DD 21 31 8E        ld ix,ssprit        ; default to spare sprite in table.
2098   7E23 CD 0D 65    evini  call evnt13         ; initialisation.
2099   7E26             
2100   7E26             ; Two restarts.
2101   7E26             ; First restart - clear all sprites and initialise everything.
2102   7E26             
2103   7E26 CD 02 7F    rstrt  call rsevt          ; restart events.
2104   7E29 CD 43 79           call xspr           ; clear sprite table.
2105   7E2C CD C3 8B           call sprlst         ; fetch pointer to screen sprites.
2106   7E2F CD 0C 8C           call ispr           ; initialise sprite table.
2107   7E32 18 0C              jr rstrt0
2108   7E34             
2109   7E34             ; Second restart - clear all but player, and don't initialise him.
2110   7E34             
2111   7E34 CD 02 7F    rstrtn call rsevt          ; restart events.
2112   7E37 CD DA 8B           call nspr           ; clear all non-player sprites.
2113   7E3A CD C3 8B           call sprlst         ; fetch pointer to screen sprites.
2114   7E3D CD 32 8C           call kspr           ; initialise sprite table, no more players.
2115   7E40             
2116   7E40             
2117   7E40             ; Set up the player and/or enemy sprites.
2118   7E40             
2119   7E40 AF          rstrt0 xor a               ; zero in accumulator.
2120   7E41 32 57 77           ld (nexlev),a       ; reset next level flag.
2121   7E44 32 58 77           ld (restfl),a       ; reset restart flag.
2122   7E47 32 59 77           ld (deadf),a        ; reset dead flag.
2123   7E4A CD 0B 84           call droom          ; show screen layout.
2124   7E4D CD C4 8E           call rbloc          ; redraw blocks if in adventure mode.
2125   7E50 CD A1 7D           call inishr         ; initialise particle engine.
2126   7E53 CD 97 80           call shwob          ; draw objects.
2127   7E56 DD 21 65 8D        ld ix,sprtab        ; address of sprite table, even sprites.
2128   7E5A CD 44 88           call dspr           ; display sprites.
2129   7E5D DD 21 76 8D        ld ix,sprtab+TABSIZ ; address of first odd sprite.
2130   7E61 CD 44 88           call dspr           ; display sprites.
2131   7E64             
2132   7E64 CD 7C 79    mloop  call vsync          ; synchronise with display.
2133   7E67             
2134   7E67 DD 21 65 8D        ld ix,sprtab        ; address of sprite table, even sprites.
2135   7E6B CD 44 88           call dspr           ; display even sprites.
2136   7E6E             
2137   7E6E CD C0 8E           call plsnd          ; play sounds.
2138   7E71 CD 7C 79           call vsync          ; synchronise with display.
2139   7E74 DD 21 76 8D        ld ix,sprtab+TABSIZ ; address of first odd sprite.
2140   7E78 CD 44 88           call dspr           ; display odd sprites.
2141   7E7B DD 21 31 8E        ld ix,ssprit        ; point to spare sprite for spawning purposes.
2142   7E7F CD 14 64    evlp1  call evnt10         ; called once per main loop.
2143   7E82 CD FF 87           call pspr           ; process sprites.
2144   7E85             
2145   7E85             ; Main loop events.
2146   7E85             
2147   7E85 DD 21 31 8E        ld ix,ssprit        ; point to spare sprite for spawning purposes.
2148   7E89 CD 5F 64    evlp2  call evnt11         ; called once per main loop.
2149   7E8C             
2150   7E8C CD B0 87    bsortx call bsort          ; sort sprites.
2151   7E8F 3A 57 77           ld a,(nexlev)       ; finished level flag.
2152   7E92 A7                 and a               ; has it been set?
2153   7E93 20 1C              jr nz,newlev        ; yes, go to next level.
2154   7E95 3A 5A 77           ld a,(gamwon)       ; finished game flag.
2155   7E98 A7                 and a               ; has it been set?
2156   7E99 20 26              jr nz,evwon         ; yes, finish the game.
2157   7E9B 3A 58 77           ld a,(restfl)       ; finished level flag.
2158   7E9E 3D                 dec a               ; has it been set?
2159   7E9F 28 85              jr z,rstrt          ; yes, go to next level.
2160   7EA1 3D                 dec a               ; has it been set?
2161   7EA2 28 90              jr z,rstrtn         ; yes, go to next level.
2162   7EA4             
2163   7EA4 3A 59 77           ld a,(deadf)        ; dead flag.
2164   7EA7 A7                 and a               ; is it non-zero?
2165   7EA8 20 1D              jr nz,pdead         ; yes, player dead.
2166   7EAA             
2167   7EAA 21 2B 77           ld hl,frmno         ; game frame.
2168   7EAD 34                 inc (hl)            ; advance the frame.
2169   7EAE             
2170   7EAE             ; Back to start of main loop.
2171   7EAE             
2172   7EAE C3 64 7E           jp DEBUG            ; debug or back to mloop.
2173   7EB1             
2174   7EB1 3A 35 77    newlev ld a,(scno)         ; current screen.
2175   7EB4 21 C7 6C           ld hl,numsc         ; total number of screens.
2176   7EB7 3C                 inc a               ; next screen.
2177   7EB8 BE                 cp (hl)             ; reached the limit?
2178   7EB9 30 06              jr nc,evwon         ; yes, game finished.
2179   7EBB 32 35 77           ld (scno),a         ; set new level number.
2180   7EBE C3 26 7E           jp rstrt            ; restart, clearing all aliens.
2181   7EC1 CD 40 66    evwon  call evnt18         ; game completed.
2182   7EC4 C3 D8 7E           jp tidyup           ; tidy up and return to BASIC/calling routine.
2183   7EC7             
2184   7EC7             ; Player dead.
2185   7EC7             
2186   7EC7 AF          pdead  xor a               ; zeroise accumulator.
2187   7EC8 32 59 77           ld (deadf),a        ; reset dead flag.
2188   7ECB CD 24 66    evdie  call evnt16         ; death subroutine.
2189   7ECE 3A 36 77           ld a,(numlif)       ; number of lives.
2190   7ED1 A7                 and a               ; reached zero yet?
2191   7ED2 C2 26 7E           jp nz,rstrt         ; restart game.
2192   7ED5 CD 36 66    evfail call evnt17         ; failure event.
2193   7ED8 21 22 82    tidyup ld hl,hiscor        ; high score.
2194   7EDB 11 1C 82           ld de,score         ; player's score.
2195   7EDE 06 06              ld b,6              ; digits to check.
2196   7EE0 1A          tidyu2 ld a,(de)           ; get score digit.
2197   7EE1 BE                 cp (hl)             ; are we larger than high score digit?
2198   7EE2 38 06              jr c,tidyu0         ; high score is bigger.
2199   7EE4 20 0C              jr nz,tidyu1        ; score is greater, record new high score.
2200   7EE6 23                 inc hl              ; next digit of high score.
2201   7EE7 13                 inc de              ; next digit of score.
2202   7EE8 10 F6              djnz tidyu2         ; repeat for all digits.
2203   7EEA 21 58 27    tidyu0 ld hl,10072         ; BASIC likes this in alternate hl.
2204   7EED D9                 exx                 ; flip hl into alternate registers.
2205   7EEE 01 1C 82           ld bc,score         ; return pointing to score.
2206   7EF1 C9                 ret
2207   7EF2 21 1C 82    tidyu1 ld hl,score         ; score.
2208   7EF5 11 22 82           ld de,hiscor        ; high score.
2209   7EF8 01 06 00           ld bc,6             ; digits to copy.
2210   7EFB ED B0              ldir                ; copy score to high score.
2211   7EFD CD 4A 66    evnewh call evnt19         ; new high score event.
2212   7F00 18 E8              jr tidyu0           ; tidy up.
2213   7F02             
2214   7F02             ; Restart event.
2215   7F02             
2216   7F02 DD 21 31 8E rsevt  ld ix,ssprit        ; default to spare element in table.
2217   7F06 C3 B9 65    evrs   jp evnt14           ; call restart event.
2218   7F09             
2219   7F09             ; Copy number passed in a to string position bc, right-justified.
2220   7F09             
2221   7F09 6F          num2ch ld l,a              ; put accumulator in l.
2222   7F0A 26 00              ld h,0              ; blank high byte of hl.
2223   7F0C 3E 20              ld a,32             ; leading spaces.
2224   7F0E 11 64 00    numdg3 ld de,100           ; hundreds column.
2225   7F11 CD 1F 7F           call numdg          ; show digit.
2226   7F14 11 0A 00    numdg2 ld de,10            ; tens column.
2227   7F17 CD 1F 7F           call numdg          ; show digit.
2228   7F1A F6 10              or 16               ; last digit is always shown.
2229   7F1C 11 01 00           ld de,1             ; units column.
2230   7F1F E6 30       numdg  and 48              ; clear carry, clear digit.
2231   7F21 ED 52       numdg1 sbc hl,de           ; subtract from column.
2232   7F23 38 05              jr c,numdg0         ; nothing to show.
2233   7F25 F6 10              or 16               ; something to show, make it a digit.
2234   7F27 3C                 inc a               ; increment digit.
2235   7F28 18 F7              jr numdg1           ; repeat until column is zero.
2236   7F2A 19          numdg0 add hl,de           ; restore total.
2237   7F2B FE 20              cp 32               ; leading space?
2238   7F2D C8                 ret z               ; yes, don't write that.
2239   7F2E 02                 ld (bc),a           ; write digit to buffer.
2240   7F2F 03                 inc bc              ; next buffer position.
2241   7F30 C9                 ret
2242   7F31 6F          num2dd ld l,a              ; put accumulator in l.
2243   7F32 26 00              ld h,0              ; blank high byte of hl.
2244   7F34 3E 20              ld a,32             ; leading spaces.
2245   7F36 11 64 00           ld de,100           ; hundreds column.
2246   7F39 CD 1F 7F           call numdg          ; show digit.
2247   7F3C F6 10              or 16               ; second digit is always shown.
2248   7F3E 18 D4              jr numdg2
2249   7F40 6F          num2td ld l,a              ; put accumulator in l.
2250   7F41 26 00              ld h,0              ; blank high byte of hl.
2251   7F43 3E 30              ld a,48             ; leading spaces.
2252   7F45 18 C7              jr numdg3
2253   7F47             
2254   7F47 06 06       inisc  ld b,6              ; digits to initialise.
2255   7F49 36 30       inisc0 ld (hl),'0'         ; write zero digit.
2256   7F4B 23                 inc hl              ; next column.
2257   7F4C 10 FB              djnz inisc0         ; repeat for all digits.
2258   7F4E C9                 ret
2259   7F4F             
2260   7F4F             
2261   7F4F             ; Multiply h by d and return in hl.
2262   7F4F             
2263   7F4F 5A          imul   ld e,d              ; HL = H * D
2264   7F50 4C                 ld c,h              ; make c first multiplier.
2265   7F51 21 00 00    imul0  ld hl,0             ; zeroise total.
2266   7F54 54                 ld d,h              ; zeroise high byte.
2267   7F55 06 08              ld b,8              ; repeat 8 times.
2268   7F57 CB 19       imul1  rr c                ; rotate rightmost bit into carry.
2269   7F59 30 02              jr nc,imul2         ; wasn't set.
2270   7F5B 19                 add hl,de           ; bit was set, so add de.
2271   7F5C A7                 and a               ; reset carry.
2272   7F5D CB 13       imul2  rl e                ; shift de 1 bit left.
2273   7F5F CB 12              rl d
2274   7F61 10 F4              djnz imul1          ; repeat 8 times.
2275   7F63 C9                 ret
2276   7F64             
2277   7F64             ; Divide d by e and return in d, remainder in a.
2278   7F64             
2279   7F64 AF          idiv   xor a
2280   7F65 06 08              ld b,8              ; bits to shift.
2281   7F67 CB 22       idiv0  sla d               ; multiply d by 2.
2282   7F69 17                 rla                 ; shift carry into remainder.
2283   7F6A BB                 cp e                ; test if e is smaller.
2284   7F6B 38 02              jr c,idiv1          ; e is greater, no division this time.
2285   7F6D 93                 sub e               ; subtract it.
2286   7F6E 14                 inc d               ; rotate into d.
2287   7F6F 10 F6       idiv1  djnz idiv0
2288   7F71 C9                 ret
2289   7F72             
2290   7F72             ; Initialise a sound.
2291   7F72             
2292   7F72 ED 5B 97 7F isnd   ld de,(ch1ptr)      ; first pointer.
2293   7F76 1A                 ld a,(de)           ; get first byte.
2294   7F77 3C                 inc a               ; reached the end?
2295   7F78 28 11              jr z,isnd1          ; that'll do.
2296   7F7A ED 5B 99 7F        ld de,(ch2ptr)      ; second pointer.
2297   7F7E 1A                 ld a,(de)           ; get first byte.
2298   7F7F 3C                 inc a               ; reached the end?
2299   7F80 28 0D              jr z,isnd2          ; that'll do.
2300   7F82 ED 5B 9B 7F        ld de,(ch3ptr)      ; final pointer.
2301   7F86 1A                 ld a,(de)           ; get first byte.
2302   7F87 3C                 inc a               ; reached the end?
2303   7F88 28 09              jr z,isnd3          ; that'll do.
2304   7F8A C9                 ret
2305   7F8B 22 97 7F    isnd1  ld (ch1ptr),hl      ; set up the sound.
2306   7F8E C9                 ret
2307   7F8F 22 99 7F    isnd2  ld (ch2ptr),hl      ; set up the sound.
2308   7F92 C9                 ret
2309   7F93 22 9B 7F    isnd3  ld (ch3ptr),hl      ; set up the sound.
2310   7F96 C9                 ret
2311   7F97             
2312   7F97             
2313   7F97 09 89       ch1ptr defw spmask
2314   7F99 09 89       ch2ptr defw spmask
2315   7F9B 09 89       ch3ptr defw spmask
2316   7F9D             
2317   7F9D             ;plsnd  call plsnd1         ; first channel.
2318   7F9D             ;       call plsnd2         ; second one.
2319   7F9D             ;       call plsnd3         ; final channel.
2320   7F9D             
2321   7F9D             ; Write the contents of our AY buffer to the AY registers.
2322   7F9D             
2323   7F9D 21 B5 7F    w8912  ld hl,snddat        ; start of AY-3-8912 register data.
2324   7FA0 11 00 0E           ld de,14*256        ; start with register 0, 14 to write.
2325   7FA3 0E FD              ld c,253            ; low byte of port to write.
2326   7FA5 06 FF       w8912a ld b,255            ; port 65533=select soundchip register.
2327   7FA7 ED 59              out (c),e           ; tell chip which register we're writing.
2328   7FA9 7E                 ld a,(hl)           ; value to write.
2329   7FAA 06 BF              ld b,191            ; port 49149=write value to register.
2330   7FAC ED 79              out (c),a           ; this is what we're putting there.
2331   7FAE 1C                 inc e               ; next sound chip register.
2332   7FAF 23                 inc hl              ; next byte to write.
2333   7FB0 15                 dec d               ; decrement loop counter.
2334   7FB1 C2 A5 7F           jp nz,w8912a        ; repeat until done.
2335   7FB4 C9                 ret
2336   7FB5             
2337   7FB5 00 00       snddat defw 0              ; tone registers, channel A.
2338   7FB7 00 00              defw 0              ; channel B tone registers.
2339   7FB9 00 00              defw 0              ; as above, channel C.
2340   7FBB 00          sndwnp defb 0              ; white noise period.
2341   7FBC 3C          sndmix defb 60             ; tone/noise mixer control.
2342   7FBD 00          sndv1  defb 0              ; channel A amplitude/envelope generator.
2343   7FBE 00          sndv2  defb 0              ; channel B amplitude/envelope.
2344   7FBF 00          sndv3  defb 0              ; channel C amplitude/envelope.
2345   7FC0 00 00              defw 0              ; duration of each note.
2346   7FC2 00                 defb 0
2347   7FC3             
2348   7FC3 23          plwn   inc hl              ; next byte of sound.
2349   7FC4 E6 38              and 56              ; check if we're bothering with white noise.
2350   7FC6 C0                 ret nz              ; we're not.
2351   7FC7 7E                 ld a,(hl)           ; fetch byte.
2352   7FC8 32 BB 7F           ld (sndwnp),a       ; set white noise period.
2353   7FCB C9                 ret
2354   7FCC             
2355   7FCC             
2356   7FCC CD 62 80    plsnd2 call cksnd2         ; check sound for first channel.
2357   7FCF FE FF              cp 255              ; reached end?
2358   7FD1 28 70              jr z,silen2         ; silence this channel.
2359   7FD3 E6 0F              and 15              ; sound bits.
2360   7FD5 32 BE 7F           ld (sndv2),a        ; set volume for channel.
2361   7FD8 3A BC 7F           ld a,(sndmix)       ; mixer byte.
2362   7FDB E6 ED              and 237             ; remove bits for this channel.
2363   7FDD 47                 ld b,a              ; store in b register.
2364   7FDE CD 22 80           call plmix          ; fetch mixer details.
2365   7FE1 E6 12              and 18              ; mixer bits we want.
2366   7FE3 B0                 or b                ; combine with mixer bits.
2367   7FE4 32 BC 7F           ld (sndmix),a       ; new mixer value.
2368   7FE7 CD C3 7F           call plwn           ; white noise check.
2369   7FEA 23                 inc hl              ; tone low.
2370   7FEB 5E                 ld e,(hl)           ; fetch value.
2371   7FEC 23                 inc hl              ; tone high.
2372   7FED 56                 ld d,(hl)           ; fetch value.
2373   7FEE ED 53 B7 7F        ld (snddat+2),de    ; set tone.
2374   7FF2 23                 inc hl              ; next bit of sound.
2375   7FF3 22 99 7F           ld (ch2ptr),hl      ; set pointer.
2376   7FF6 C9                 ret
2377   7FF7             
2378   7FF7 CD 67 80    plsnd3 call cksnd3         ; check sound for first channel.
2379   7FFA FE FF              cp 255              ; reached end?
2380   7FFC 28 52              jr z,silen3         ; silence last channel.
2381   7FFE E6 0F              and 15              ; sound bits.
2382   8000 32 BF 7F           ld (sndv3),a        ; set volume for channel.
2383   8003 3A BC 7F           ld a,(sndmix)       ; mixer byte.
2384   8006 E6 DB              and 219             ; remove bits for this channel.
2385   8008 47                 ld b,a              ; store in b register.
2386   8009 CD 22 80           call plmix          ; fetch mixer details.
2387   800C E6 24              and 36              ; mixer bits we want.
2388   800E B0                 or b                ; combine with mixer bits.
2389   800F 32 BC 7F           ld (sndmix),a       ; new mixer value.
2390   8012 CD C3 7F           call plwn           ; white noise check.
2391   8015 23                 inc hl              ; tone low.
2392   8016 5E                 ld e,(hl)           ; fetch value.
2393   8017 23                 inc hl              ; tone high.
2394   8018 56                 ld d,(hl)           ; fetch value.
2395   8019 ED 53 B9 7F        ld (snddat+4),de    ; set tone.
2396   801D 23                 inc hl              ; next bit of sound.
2397   801E 22 9B 7F           ld (ch3ptr),hl      ; set pointer.
2398   8021 C9                 ret
2399   8022             
2400   8022 7E          plmix  ld a,(hl)           ; fetch mixer byte.
2401   8023 E6 C0              and 192             ; mix bits are d6 and d7.
2402   8025 07                 rlca                ; rotate into d0 and d1.
2403   8026 07                 rlca
2404   8027 5F                 ld e,a              ; displacement in de.
2405   8028 16 00              ld d,0
2406   802A E5                 push hl             ; store pointer on stack.
2407   802B 21 32 80           ld hl,mixtab        ; mixer table.
2408   802E 19                 add hl,de           ; point to mixer byte.
2409   802F 7E                 ld a,(hl)           ; fetch mixer value.
2410   8030 E1                 pop hl              ; restore pointer.
2411   8031 C9                 ret
2412   8032 3F 38 07 00 mixtab defb 63,56,7,0      ; mixer byte settings.
2413   8036             
2414   8036 AF          silen1 xor a               ; zero.
2415   8037 32 BD 7F           ld (sndv1),a        ; sound off.
2416   803A 3A BC 7F           ld a,(sndmix)       ; mixer byte.
2417   803D F6 09              or 9                ; mix bits off.
2418   803F 32 BC 7F           ld (sndmix),a       ; mixer setting for channel.
2419   8042 C9                 ret
2420   8043 AF          silen2 xor a               ; zero.
2421   8044 32 BE 7F           ld (sndv2),a        ; sound off.
2422   8047 3A BC 7F           ld a,(sndmix)       ; mixer byte.
2423   804A F6 12              or 18               ; mix bits off.
2424   804C 32 BC 7F           ld (sndmix),a       ; mixer setting for channel.
2425   804F C9                 ret
2426   8050 AF          silen3 xor a               ; zero.
2427   8051 32 BF 7F           ld (sndv3),a        ; sound off.
2428   8054 3A BC 7F           ld a,(sndmix)       ; mixer byte.
2429   8057 F6 24              or 36               ; mix bits off.
2430   8059 32 BC 7F           ld (sndmix),a       ; mixer setting for channel.
2431   805C C9                 ret
2432   805D 2A 97 7F    cksnd1 ld hl,(ch1ptr)      ; pointer to sound.
2433   8060 7E                 ld a,(hl)           ; fetch mixer/flag.
2434   8061 C9                 ret
2435   8062 2A 99 7F    cksnd2 ld hl,(ch2ptr)      ; pointer to sound.
2436   8065 7E                 ld a,(hl)           ; fetch mixer/flag.
2437   8066 C9                 ret
2438   8067 2A 9B 7F    cksnd3 ld hl,(ch3ptr)      ; pointer to sound.
2439   806A 7E                 ld a,(hl)           ; fetch mixer/flag.
2440   806B C9                 ret
2441   806C             
2442   806C CD 5D 80    plsnd1 call cksnd1         ; check sound for first channel.
2443   806F FE FF              cp 255              ; reached end?
2444   8071 28 C3              jr z,silen1         ; silence first channel.
2445   8073 E6 0F              and 15              ; sound bits.
2446   8075 32 BD 7F           ld (sndv1),a        ; set volume for channel.
2447   8078 3A BC 7F           ld a,(sndmix)       ; mixer byte.
2448   807B E6 F6              and 246             ; remove bits for this channel.
2449   807D 47                 ld b,a              ; store in b register.
2450   807E CD 22 80           call plmix          ; fetch mixer details.
2451   8081 E6 09              and 9               ; mixer bits we want.
2452   8083 B0                 or b                ; combine with mixer bits.
2453   8084 32 BC 7F           ld (sndmix),a       ; new mixer value.
2454   8087 CD C3 7F           call plwn           ; white noise check.
2455   808A 23                 inc hl              ; tone low.
2456   808B 5E                 ld e,(hl)           ; fetch value.
2457   808C 23                 inc hl              ; tone high.
2458   808D 56                 ld d,(hl)           ; fetch value.
2459   808E ED 53 B5 7F        ld (snddat),de      ; set tone.
2460   8092 23                 inc hl              ; next bit of sound.
2461   8093 22 97 7F           ld (ch1ptr),hl      ; set pointer.
2462   8096 C9                 ret
2463   8097             
2464   8097             
2465   8097             ; Objects handling.
2466   8097             ; 32 bytes for image
2467   8097             ; 1 for colour
2468   8097             ; 3 for room, x and y
2469   8097             ; 3 for starting room, x and y.
2470   8097             ; 254 = disabled.
2471   8097             ; 255 = object in player's pockets.
2472   8097             
2473   8097             ; Show items present.
2474   8097             
2475   8097 21 4A 73    shwob  ld hl,objdta        ; objects table.
2476   809A 11 21 00           ld de,33            ; distance to room number.
2477   809D 19                 add hl,de           ; point to room data.
2478   809E 3A 30 77           ld a,(numob)        ; number of objects in the game.
2479   80A1 47                 ld b,a              ; loop counter.
2480   80A2 C5          shwob0 push bc             ; store count.
2481   80A3 E5                 push hl             ; store item pointer.
2482   80A4 3A 35 77           ld a,(scno)         ; current location.
2483   80A7 BE                 cp (hl)             ; same as an item?
2484   80A8 CC C3 80           call z,dobjc        ; yes, display object in colour.
2485   80AB E1                 pop hl              ; restore pointer.
2486   80AC C1                 pop bc              ; restore counter.
2487   80AD 11 27 00           ld de,39            ; distance to next item.
2488   80B0 19                 add hl,de           ; point to it.
2489   80B1 10 EF              djnz shwob0         ; repeat for others.
2490   80B3 C9                 ret
2491   80B4             
2492   80B4             ; Display object.
2493   80B4             ; hl must point to object's room number.
2494   80B4             
2495   80B4 23          dobj   inc hl              ; point to x.
2496   80B5 11 5B 77    dobj0  ld de,dispx         ; coordinates.
2497   80B8 ED A0              ldi                 ; transfer x coord.
2498   80BA ED A0              ldi                 ; transfer y too.
2499   80BC 11 DC FF           ld de,65500         ; minus 36.
2500   80BF 19                 add hl,de           ; point to image.
2501   80C0 C3 99 83    dobj1  jp sprite           ; draw this sprite.
2502   80C3             
2503   80C3 CD B4 80    dobjc  call dobj           ; display object.
2504   80C6 4E                 ld c,(hl)           ; put ink in c register.
2505   80C7             
2506   80C7             ; Need to write attribute routine here.
2507   80C7             ; set up colour in c register first.
2508   80C7             
2509   80C7 7E          cobj   ld a,(hl)           ; get colour byte.
2510   80C8 A7                 and a               ; test it.
2511   80C9 F8                 ret m               ; colour not set.
2512   80CA 26 16              ld h,22             ; quarter of attrubte address.
2513   80CC 3A 5B 77           ld a,(dispx)        ; x coord.
2514   80CF E6 F8              and 248             ; only want multiple of 8.
2515   80D1 17                 rla                 ; multiply by 4.
2516   80D2 CB 14              rl h
2517   80D4 17                 rla
2518   80D5 CB 14              rl h                ; high byte now set up.
2519   80D7 6F                 ld l,a
2520   80D8 3A 5C 77           ld a,(dispy)        ; take y position.
2521   80DB 1F                 rra                 ; divide it by 8.
2522   80DC 1F                 rra
2523   80DD 1F                 rra
2524   80DE E6 1F              and 31              ; remove unwanted bits.
2525   80E0 85                 add a,l             ; add to low byte.
2526   80E1 6F                 ld l,a              ; low byte of address.
2527   80E2                    
2528   80E2 11 1E 00           ld de,30            ; distance to next line down.
2529   80E5 3A 5B 77           ld a,(dispx)        ; x coordinate.
2530   80E8 06 03              ld b,3              ; default rows to write.
2531   80EA E6 07              and 7               ; does x straddle cells?
2532   80EC 20 01              jr nz,cobj0         ; yes, loop counter is good.
2533   80EE 05                 dec b               ; one less row to write.
2534   80EF 7E          cobj0  ld a,(hl)           ; get attributes.
2535   80F0 E6 F8              and 248             ; remove ink.
2536   80F2 B1                 or c                ; put in the new ink.
2537   80F3 77                 ld (hl),a           ; write back again.
2538   80F4 2C                 inc l               ; next cell.
2539   80F5 7E                 ld a,(hl)           ; get attributes.
2540   80F6 E6 F8              and 248             ; remove ink.
2541   80F8 B1                 or c                ; put in the new ink.
2542   80F9 77                 ld (hl),a           ; write back again.
2543   80FA 2C                 inc l               ; next cell.
2544   80FB 3A 5C 77           ld a,(dispy)        ; y coordinate.
2545   80FE E6 07              and 7               ; straddling cells?
2546   8100 28 05              jr z,cobj1          ; no, only 2 wide.
2547   8102 7E                 ld a,(hl)           ; get attributes.
2548   8103 E6 F8              and 248             ; remove ink.
2549   8105 B1                 or c                ; put in the new ink.
2550   8106 77                 ld (hl),a           ; write back again.
2551   8107 19          cobj1  add hl,de           ; next row.
2552   8108 10 E5              djnz cobj0
2553   810A C9                 ret
2554   810B             
2555   810B             ; Remove an object.
2556   810B             
2557   810B 21 30 77    remob  ld hl,numob         ; number of objects in game.
2558   810E BE                 cp (hl)             ; are we checking past the end?
2559   810F D0                 ret nc              ; yes, can't get non-existent item.
2560   8110 F5                 push af             ; remember object.
2561   8111 CD 1B 81           call getob          ; pick it up if we haven't already got it.
2562   8114 F1                 pop af              ; retrieve object number.
2563   8115 CD 49 81           call gotob          ; get its address.
2564   8118 36 FE              ld (hl),254         ; remove it.
2565   811A C9                 ret
2566   811B             
2567   811B             ; Pick up object number held in the accumulator.
2568   811B             
2569   811B 21 30 77    getob  ld hl,numob         ; number of objects in game.
2570   811E BE                 cp (hl)             ; are we checking past the end?
2571   811F D0                 ret nc              ; yes, can't get non-existent item.
2572   8120 CD 49 81           call gotob          ; check if we already have it.
2573   8123 C8                 ret z               ; we already do.
2574   8124 EB                 ex de,hl            ; object address in de.
2575   8125 21 35 77           ld hl,scno          ; current screen.
2576   8128 BE                 cp (hl)             ; is it on this screen?
2577   8129 EB                 ex de,hl            ; object address back in hl.
2578   812A 20 1A              jr nz,getob0        ; not on screen, so nothing to delete.
2579   812C 36 FF              ld (hl),255         ; pick it up.
2580   812E 23                 inc hl              ; point to x coord.
2581   812F 5E          getob1 ld e,(hl)           ; x coord.
2582   8130 23                 inc hl              ; back to y coord.
2583   8131 56                 ld d,(hl)           ; y coord.
2584   8132 ED 53 5B 77        ld (dispx),de       ; set display coords.
2585   8136 11 DD FF           ld de,65501         ; minus graphic size.
2586   8139 19                 add hl,de           ; point to graphics.
2587   813A CD C0 80           call dobj1          ; delete object sprite.
2588   813D 3A F0 6C           ld a,(bcol)         ; first block colour.
2589   8140 E6 07              and 7               ; only want ink attribute.
2590   8142 4F                 ld c,a              ; set up colour.
2591   8143 C3 C7 80           jp cobj             ; colour object's old position.
2592   8146 36 FF       getob0 ld (hl),255         ; pick it up.
2593   8148 C9                 ret
2594   8149             
2595   8149             ; Got object check.
2596   8149             ; Call with object in accumulator, returns zero set if in pockets.
2597   8149             
2598   8149 21 30 77    gotob  ld hl,numob         ; number of objects in game.
2599   814C BE                 cp (hl)             ; are we checking past the end?
2600   814D 30 06              jr nc,gotob0        ; yes, we can't have a non-existent object.
2601   814F CD 59 81           call findob         ; find the object.
2602   8152 FE FF       gotob1 cp 255              ; in pockets?
2603   8154 C9                 ret
2604   8155 3E FE       gotob0 ld a,254            ; missing.
2605   8157 18 F9              jr gotob1
2606   8159             
2607   8159 21 4A 73    findob ld hl,objdta        ; objects.
2608   815C 11 27 00           ld de,39            ; size of each object.
2609   815F A7                 and a               ; is it zero?
2610   8160 28 04              jr z,fndob1         ; yes, skip loop.
2611   8162 47                 ld b,a              ; loop counter in b.
2612   8163 19          fndob2 add hl,de           ; point to next one.
2613   8164 10 FD              djnz fndob2         ; repeat until we find address.
2614   8166 1E 21       fndob1 ld e,33             ; distance to room it's in.
2615   8168 19                 add hl,de           ; point to room.
2616   8169 7E                 ld a,(hl)           ; fetch status.
2617   816A C9                 ret
2618   816B             
2619   816B             ; Drop object number at (dispx, dispy).
2620   816B             
2621   816B 21 30 77    drpob  ld hl,numob         ; number of objects in game.
2622   816E BE                 cp (hl)             ; are we checking past the end?
2623   816F D0                 ret nc              ; yes, can't drop non-existent item.
2624   8170 CD 49 81           call gotob          ; make sure object is in inventory.
2625   8173 3A 35 77           ld a,(scno)         ; screen number.
2626   8176 BE                 cp (hl)             ; already on this screen?
2627   8177 C8                 ret z               ; yes, nothing to do.
2628   8178 77                 ld (hl),a           ; bring onto screen.
2629   8179 23                 inc hl              ; point to x coord.
2630   817A 3A 5B 77           ld a,(dispx)        ; sprite x coordinate.
2631   817D 77                 ld (hl),a           ; set x coord.
2632   817E 23                 inc hl              ; point to object y.
2633   817F 3A 5C 77           ld a,(dispy)        ; sprite y coordinate.
2634   8182 77                 ld (hl),a           ; set the y position.
2635   8183 11 DD FF           ld de,65501         ; minus graphic size.
2636   8186 19                 add hl,de           ; point to graphics.
2637   8187 CD C0 80           call dobj1          ; delete object sprite.
2638   818A 4E                 ld c,(hl)           ; put ink in c register.
2639   818B C3 C7 80           jp cobj             ; colour the object.
2640   818E             
2641   818E             ; Seek objects at sprite position.
2642   818E             
2643   818E 21 4A 73    skobj  ld hl,objdta        ; pointer to objects.
2644   8191 11 21 00           ld de,33            ; distance to room number.
2645   8194 19                 add hl,de           ; point to room data.
2646   8195 11 27 00           ld de,39            ; size of each object.
2647   8198 3A 30 77           ld a,(numob)        ; number of objects in game.
2648   819B 47                 ld b,a              ; set up the loop counter.
2649   819C 3A 35 77    skobj0 ld a,(scno)         ; current room number.
2650   819F BE                 cp (hl)             ; is object in here?
2651   81A0 CC A9 81           call z,skobj1       ; yes, check coordinates.
2652   81A3 19                 add hl,de           ; point to next object in table.
2653   81A4 10 F6              djnz skobj0         ; repeat for all objects.
2654   81A6 3E FF              ld a,255            ; end of list and nothing found, return 255.
2655   81A8 C9                 ret
2656   81A9 23          skobj1 inc hl              ; point to x coordinate.
2657   81AA 7E                 ld a,(hl)           ; get coordinate.
2658   81AB DD 96 08           sub (ix+8)          ; subtract sprite x.
2659   81AE C6 0F              add a,15            ; add sprite height minus one.
2660   81B0 FE 1F              cp 31               ; within range?
2661   81B2 D2 C8 81           jp nc,skobj2        ; no, ignore object.
2662   81B5 23                 inc hl              ; point to y coordinate now.
2663   81B6 7E                 ld a,(hl)           ; get coordinate.
2664   81B7 DD 96 09           sub (ix+9)          ; subtract the sprite y.
2665   81BA C6 0F              add a,15            ; add sprite width minus one.
2666   81BC FE 1F              cp 31               ; within range?
2667   81BE D2 C7 81           jp nc,skobj3        ; no, ignore object.
2668   81C1 D1                 pop de              ; remove return address from stack.
2669   81C2 3A 30 77           ld a,(numob)        ; objects in game.
2670   81C5 90                 sub b               ; subtract loop counter.
2671   81C6 C9                 ret                 ; accumulator now points to object.
2672   81C7 2B          skobj3 dec hl              ; back to y position.
2673   81C8 2B          skobj2 dec hl              ; back to room.
2674   81C9 C9                 ret
2675   81CA             
2676   81CA             
2677   81CA             ; Spawn a new sprite.
2678   81CA             
2679   81CA 21 65 8D    spawn  ld hl,sprtab        ; sprite table.
2680   81CD 3E 0C       numsp1 ld a,NUMSPR         ; number of sprites.
2681   81CF 11 11 00           ld de,TABSIZ        ; size of each entry.
2682   81D2 08          spaw0  ex af,af'           ; store loop counter.
2683   81D3 7E                 ld a,(hl)           ; get sprite type.
2684   81D4 3C                 inc a               ; is it an unused slot?
2685   81D5 28 05              jr z,spaw1          ; yes, we can use this one.
2686   81D7 19                 add hl,de           ; point to next sprite in table.
2687   81D8 08                 ex af,af'           ; restore loop counter.
2688   81D9 3D                 dec a               ; one less iteration.
2689   81DA 20 F6              jr nz,spaw0         ; keep going until we find a slot.
2690   81DC             
2691   81DC             ; Didn't find one but drop through and set up a dummy sprite instead.
2692   81DC             
2693   81DC DD E5       spaw1  push ix             ; existing sprite address on stack.
2694   81DE 22 19 82           ld (spptr),hl       ; store spawned sprite address.
2695   81E1 71                 ld (hl),c           ; set the type.
2696   81E2 23                 inc hl              ; point to image.
2697   81E3 70                 ld (hl),b           ; set the image.
2698   81E4 23                 inc hl              ; next byte.
2699   81E5 36 00              ld (hl),0           ; frame zero.
2700   81E7 23                 inc hl              ; next byte.
2701   81E8 DD 7E 08           ld a,(ix+X)         ; x coordinate.
2702   81EB 77                 ld (hl),a           ; set sprite coordinate.
2703   81EC 23                 inc hl              ; next byte.
2704   81ED DD 7E 09           ld a,(ix+Y)         ; y coordinate.
2705   81F0 77                 ld (hl),a           ; set sprite coordinate.
2706   81F1 23                 inc hl              ; next byte.
2707   81F2 EB                 ex de,hl            ; swap address into de.
2708   81F3 2A 19 82           ld hl,(spptr)       ; restore address of details.
2709   81F6 01 05 00           ld bc,5             ; number of bytes to duplicate.
2710   81F9 ED B0              ldir                ; copy first version to new version.
2711   81FB EB                 ex de,hl            ; swap address into de.
2712   81FC DD 7E 0A           ld a,(ix+10)        ; direction of original.
2713   81FF 77                 ld (hl),a           ; set the direction.
2714   8200 23                 inc hl              ; next byte.
2715   8201 70                 ld (hl),b           ; reset parameter.
2716   8202 23                 inc hl              ; next byte.
2717   8203 70                 ld (hl),b           ; reset parameter.
2718   8204 23                 inc hl              ; next byte.
2719   8205 70                 ld (hl),b           ; reset parameter.
2720   8206 23                 inc hl              ; next byte.
2721   8207 70                 ld (hl),b           ; reset parameter.
2722   8208 DD 2A 19 82 rtssp  ld ix,(spptr)       ; address of new sprite.
2723   820C CD FB 63    evis1  call evnt09         ; call sprite initialisation event.
2724   820F DD 2A 19 82        ld ix,(spptr)       ; address of new sprite.
2725   8213 CD 11 89           call sspria         ; display the new sprite.
2726   8216 DD E1              pop ix              ; address of original sprite.
2727   8218 C9                 ret
2728   8219             
2729   8219 00 00       spptr  defw 0              ; spawned sprite pointer.
2730   821B 00          seed   defb 0              ; seed for random numbers.
2731   821C             score  defb '000000'       ; player's score.
2731   821C 303030303030
2732   8222             hiscor defb '000000'       ; high score.
2732   8222 303030303030
2733   8228             bonus  defb '000000'       ; bonus.
2733   8228 303030303030
2734   822E 00 3C       grbase defw 15360          ; graphics base address.
2735   8230             
2736   8230 7B          checkx ld a,e              ; x position.
2737   8231 FE 18              cp 24               ; off screen?
2738   8233 D8                 ret c               ; no, it's okay.
2739   8234 E1                 pop hl              ; remove return address from stack.
2740   8235 C9                 ret
2741   8236             
2742   8236             ; Displays the current score.
2743   8236             
2744   8236 CD 93 87    dscor  call preprt         ; set up font and print position.
2745   8239 CD 30 82           call checkx         ; make sure we're in a printable range.
2746   823C 3A 00 87           ld a,(prtmod)       ; get print mode.
2747   823F A7                 and a               ; standard size text?
2748   8240 C2 66 82           jp nz,bscor0        ; no, show double-height.
2749   8243 C5          dscor0 push bc             ; place counter onto the stack.
2750   8244 E5                 push hl
2751   8245 7E                 ld a,(hl)           ; fetch character.
2752   8246 CD 26 83           call pchar          ; display character.
2753   8249 CD 0E 83           call gaadd          ; get attribute address.
2754   824C 3A 8D 5C           ld a,(23693)        ; current cell colours.
2755   824F 77                 ld (hl),a           ; write to attribute cell.
2756   8250 21 5C 77           ld hl,dispy         ; y coordinate.
2757   8253 34                 inc (hl)            ; move along one.
2758   8254 E1                 pop hl
2759   8255 23                 inc hl              ; next score column.
2760   8256 C1                 pop bc              ; retrieve character counter.
2761   8257 10 EA              djnz dscor0         ; repeat for all digits.
2762   8259 2A 5F 77           ld hl,(blkptr)      ; blocks.
2763   825C 22 2E 82           ld (grbase),hl      ; set graphics base.
2764   825F 2A 5B 77    dscor2 ld hl,(dispx)       ; general coordinates.
2765   8262 22 50 77           ld (charx),hl       ; set up display coordinates.
2766   8265 C9                 ret
2767   8266             
2768   8266             ; Displays the current score in double-height characters.
2769   8266             
2770   8266 C5          bscor0 push bc             ; place counter onto the stack.
2771   8267 E5                 push hl
2772   8268 7E                 ld a,(hl)           ; fetch character.
2773   8269 CD 24 87           call bchar          ; display big char.
2774   826C E1                 pop hl
2775   826D 23                 inc hl              ; next score column.
2776   826E C1                 pop bc              ; retrieve character counter.
2777   826F 10 F5              djnz bscor0         ; repeat for all digits.
2778   8271 C3 5F 82           jp dscor2           ; tidy up line and column variables.
2779   8274             
2780   8274             ; Adds number in the hl pair to the score.
2781   8274             
2782   8274 11 1D 82    addsc  ld de,score+1       ; ten thousands column.
2783   8277 01 10 27           ld bc,10000         ; amount to add each time.
2784   827A CD 96 82           call incsc          ; add to score.
2785   827D 13                 inc de              ; thousands column.
2786   827E 01 E8 03           ld bc,1000          ; amount to add each time.
2787   8281 CD 96 82           call incsc          ; add to score.
2788   8284 13                 inc de              ; hundreds column.
2789   8285 01 64 00           ld bc,100           ; amount to add each time.
2790   8288 CD 96 82           call incsc          ; add to score.
2791   828B 13                 inc de              ; tens column.
2792   828C 01 0A 00           ld bc,10            ; amount to add each time.
2793   828F CD 96 82           call incsc          ; add to score.
2794   8292 13                 inc de              ; units column.
2795   8293 01 01 00           ld bc,1             ; units.
2796   8296 E5          incsc  push hl             ; store amount to add.
2797   8297 A7                 and a               ; clear the carry flag.
2798   8298 ED 42              sbc hl,bc           ; subtract from amount to add.
2799   829A 38 09              jr c,incsc0         ; too much, restore value.
2800   829C F1                 pop af              ; delete the previous amount from the stack.
2801   829D D5                 push de             ; store column position.
2802   829E CD A7 82           call incsc2         ; do the increment.
2803   82A1 D1                 pop de              ; restore column.
2804   82A2 C3 96 82           jp incsc            ; repeat until all added.
2805   82A5 E1          incsc0 pop hl              ; restore previous value.
2806   82A6 C9                 ret
2807   82A7 1A          incsc2 ld a,(de)           ; get amount.
2808   82A8 3C                 inc a               ; add one to column.
2809   82A9 12                 ld (de),a           ; write new column total.
2810   82AA FE 3A              cp '9'+1            ; gone beyond range of digits?
2811   82AC D8                 ret c               ; no, carry on.
2812   82AD 3E 30              ld a,'0'            ; mae it zero.
2813   82AF 12                 ld (de),a           ; write new column total.
2814   82B0 1B                 dec de              ; back one column.
2815   82B1 18 F4              jr incsc2
2816   82B3             
2817   82B3             ; Add bonus to score.
2818   82B3             
2819   82B3 11 21 82    addbo  ld de,score+5       ; last score digit.
2820   82B6 21 2D 82           ld hl,bonus+5       ; last bonus digit.
2821   82B9 A7                 and a               ; clear carry.
2822   82BA 01 30 06           ld bc,6*256+48      ; 6 digits to add, ASCII '0' in c.
2823   82BD 1A          addbo0 ld a,(de)           ; get score.
2824   82BE 8E                 adc a,(hl)          ; add bonus.
2825   82BF 91                 sub c               ; 0 to 18.
2826   82C0 71                 ld (hl),c           ; zeroise bonus.
2827   82C1 2B                 dec hl              ; next bonus.
2828   82C2 FE 3A              cp 58               ; carried?
2829   82C4 38 02              jr c,addbo1         ; no, do next one.
2830   82C6 D6 0A              sub 10              ; subtract 10.
2831   82C8 12          addbo1 ld (de),a           ; write new score.
2832   82C9 1B                 dec de              ; next score digit.
2833   82CA 3F                 ccf                 ; set carry for next digit.
2834   82CB 10 F0              djnz addbo0         ; repeat for all 6 digits.
2835   82CD C9                 ret
2836   82CE             
2837   82CE             ; Swap score and bonus.
2838   82CE             
2839   82CE 11 1C 82    swpsb  ld de,score         ; first score digit.
2840   82D1 21 28 82           ld hl,bonus         ; first bonus digit.
2841   82D4 06 06              ld b,6              ; digits to add.
2842   82D6 1A          swpsb0 ld a,(de)           ; get score and bonus digits.
2843   82D7 4E                 ld c,(hl)
2844   82D8 EB                 ex de,hl            ; swap pointers.
2845   82D9 71                 ld (hl),c           ; write bonus and score digits.
2846   82DA 12                 ld (de),a
2847   82DB 23                 inc hl              ; next score and bonus.
2848   82DC 13                 inc de
2849   82DD 10 F7              djnz swpsb0         ; repeat for all 6 digits.
2850   82DF C9                 ret
2851   82E0             
2852   82E0             ; Get print address.
2853   82E0             
2854   82E0 3A 5B 77    gprad  ld a,(dispx)        ; returns scr. add. in de.
2855   82E3 5F                 ld e,a              ; place in e for now.
2856   82E4 E6 18              and 24              ; which of 3 segments do we need?
2857   82E6 C6 40              add a,64            ; add 64 for start address of screen.
2858   82E8 57                 ld d,a              ; that's our high byte.
2859   82E9 7B                 ld a,e              ; restore x coordinate.
2860   82EA 0F                 rrca                ; multiply by 32.
2861   82EB 0F                 rrca
2862   82EC 0F                 rrca
2863   82ED E6 E0              and 224             ; lines within segment.
2864   82EF 5F                 ld e,a              ; set up low byte for x.
2865   82F0 3A 5C 77           ld a,(dispy)        ; now get y coordinate.
2866   82F3 83                 add a,e             ; add to low byte.
2867   82F4 5F                 ld e,a              ; final low byte.
2868   82F5 C9                 ret
2869   82F6             
2870   82F6             ; Get property buffer address of char at (dispx, dispy) in hl.
2871   82F6             
2872   82F6 3A 5B 77    pradd  ld a,(dispx)        ; x coordinate.
2873   82F9 0F                 rrca                ; multiply by 32.
2874   82FA 0F                 rrca
2875   82FB 0F                 rrca
2876   82FC 6F                 ld l,a              ; store shift in l.
2877   82FD E6 03              and 3               ; high byte bits.
2878   82FF C6 FD              add a,253           ; 88 * 256 = 64768, start of properties map.
2879   8301 67                 ld h,a              ; that's our high byte.
2880   8302 7D                 ld a,l              ; restore shift result.
2881   8303 E6 E0              and 224             ; only want low bits.
2882   8305 6F                 ld l,a              ; put into low byte.
2883   8306 3A 5C 77           ld a,(dispy)        ; fetch y coordinate.
2884   8309 E6 1F              and 31              ; should be in range 0 - 31.
2885   830B 85                 add a,l             ; add to low byte.
2886   830C 6F                 ld l,a              ; new low byte.
2887   830D C9                 ret
2888   830E             
2889   830E             ; Get attribute address of char at (dispx, dispy) in hl.
2890   830E             
2891   830E 3A 5B 77    gaadd  ld a,(dispx)        ; x coordinate.
2892   8311 0F                 rrca                ; multiply by 32.
2893   8312 0F                 rrca
2894   8313 0F                 rrca
2895   8314 6F                 ld l,a              ; store shift in l.
2896   8315 E6 03              and 3               ; high byte bits.
2897   8317 C6 58              add a,88            ; 88 * 256 = 22528, start of screen attributes.
2898   8319 67                 ld h,a              ; that's our high byte.
2899   831A 7D                 ld a,l              ; restore shift result.
2900   831B E6 E0              and 224             ; only want low bits.
2901   831D 6F                 ld l,a              ; put into low byte.
2902   831E 3A 5C 77           ld a,(dispy)        ; fetch y coordinate.
2903   8321 E6 1F              and 31              ; should be in range 0 - 31.
2904   8323 85                 add a,l             ; add to low byte.
2905   8324 6F                 ld l,a              ; new low byte.
2906   8325 C9                 ret
2907   8326             
2908   8326 07          pchar  rlca                ; multiply char by 8.
2909   8327 07                 rlca
2910   8328 07                 rlca
2911   8329 5F                 ld e,a              ; store shift in e.
2912   832A E6 07              and 7               ; only want high byte bits.
2913   832C 57                 ld d,a              ; store in d.
2914   832D 7B                 ld a,e              ; restore shifted value.
2915   832E E6 F8              and 248             ; only want low byte bits.
2916   8330 5F                 ld e,a              ; that's the low byte.
2917   8331 2A 2E 82           ld hl,(grbase)      ; address of graphics.
2918   8334 19                 add hl,de           ; add displacement.
2919   8335 CD E0 82    pchark call gprad          ; get screen address.
2920   8338             ;       ldi                 ; transfer byte.
2921   8338             ;       dec de              ; back again.
2922   8338             ;       inc d               ; next screen row down.
2923   8338             ;       ldi                 ; transfer byte.
2924   8338             ;       dec de              ; back again.
2925   8338             ;       inc d               ; next screen row down.
2926   8338             ;       ldi                 ; transfer byte.
2927   8338             ;       dec de              ; back again.
2928   8338             ;       inc d               ; next screen row down.
2929   8338             ;       ldi                 ; transfer byte.
2930   8338             ;       dec de              ; back again.
2931   8338             ;       inc d               ; next screen row down.
2932   8338             ;       ldi                 ; transfer byte.
2933   8338             ;       dec de              ; back again.
2934   8338             ;       inc d               ; next screen row down.
2935   8338             ;       ldi                 ; transfer byte.
2936   8338             ;       dec de              ; back again.
2937   8338             ;       inc d               ; next screen row down.
2938   8338             ;       ldi                 ; transfer byte.
2939   8338             ;       dec de              ; back again.
2940   8338             ;       inc d               ; next screen row down.
2941   8338             ;       ldi                 ; transfer byte.
2942   8338 7E                 ld a,(hl)           ; get image byte.
2943   8339 12                 ld (de),a           ; copy to screen.
2944   833A 23                 inc hl              ; next image byte.
2945   833B 14                 inc d               ; next screen row down.
2946   833C 7E                 ld a,(hl)           ; get image byte.
2947   833D 12                 ld (de),a           ; copy to screen.
2948   833E 23                 inc hl              ; next image byte.
2949   833F 14                 inc d               ; next screen row down.
2950   8340 7E                 ld a,(hl)           ; get image byte.
2951   8341 12                 ld (de),a           ; copy to screen.
2952   8342 23                 inc hl              ; next image byte.
2953   8343 14                 inc d               ; next screen row down.
2954   8344 7E                 ld a,(hl)           ; get image byte.
2955   8345 12                 ld (de),a           ; copy to screen.
2956   8346 23                 inc hl              ; next image byte.
2957   8347 14                 inc d               ; next screen row down.
2958   8348 7E                 ld a,(hl)           ; get image byte.
2959   8349 12                 ld (de),a           ; copy to screen.
2960   834A 23                 inc hl              ; next image byte.
2961   834B 14                 inc d               ; next screen row down.
2962   834C 7E                 ld a,(hl)           ; get image byte.
2963   834D 12                 ld (de),a           ; copy to screen.
2964   834E 23                 inc hl              ; next image byte.
2965   834F 14                 inc d               ; next screen row down.
2966   8350 7E                 ld a,(hl)           ; get image byte.
2967   8351 12                 ld (de),a           ; copy to screen.
2968   8352 23                 inc hl              ; next image byte.
2969   8353 14                 inc d               ; next screen row down.
2970   8354 7E                 ld a,(hl)           ; get image byte.
2971   8355 12                 ld (de),a           ; copy to screen.
2972   8356 C9                 ret
2973   8357             
2974   8357             ; Print attributes, properties and pixels.
2975   8357             
2976   8357 00          colpat defb 0
2977   8358             
2978   8358 47          pattr  ld b,a              ; store cell in b register for now.
2979   8359 5F                 ld e,a              ; displacement in e.
2980   835A 16 00              ld d,0              ; no high byte.
2981   835C 2A 63 77           ld hl,(proptr)      ; pointer to properties.
2982   835F 19                 add hl,de           ; property cell address.
2983   8360 4E                 ld c,(hl)           ; fetch byte.
2984   8361 79                 ld a,c              ; put into accumulator.
2985   8362 FE 08              cp COLECT           ; is it a collectable?
2986   8364 C2 6B 83           jp nz,pattr1        ; no, carry on as normal.
2987   8367 78                 ld a,b              ; restore cell.
2988   8368 32 57 83           ld (colpat),a       ; store collectable block.
2989   836B CD F6 82    pattr1 call pradd          ; get property buffer address.
2990   836E 71                 ld (hl),c           ; write property.
2991   836F 78                 ld a,b              ; get block number.
2992   8370             
2993   8370             ; Print attributes, no properties.
2994   8370             
2995   8370 5F          panp   ld e,a              ; displacement in e.
2996   8371 16 00              ld d,0              ; no high byte.
2997   8373 2A 61 77           ld hl,(colptr)      ; pointer to colours.
2998   8376 19                 add hl,de           ; colour cell address.
2999   8377 4E                 ld c,(hl)           ; fetch byte.
3000   8378 CD 0E 83           call gaadd          ; get attribute address.
3001   837B 71                 ld (hl),c           ; write colour.
3002   837C 78                 ld a,b              ; restore cell.
3003   837D             
3004   837D             ; Print character pixels, no more.
3005   837D             
3006   837D CD 26 83    pchr   call pchar          ; show character in accumulator.
3007   8380 21 5C 77           ld hl,dispy         ; y coordinate.
3008   8383 34                 inc (hl)            ; move along one.
3009   8384 C9                 ret
3010   8385             
3011   8385             ; Shifter sprite routine for objects.
3012   8385             
3013   8385 EE 07       sprit7 xor 7
3014   8387 3C                 inc a
3015   8388 CB 15       sprit3 rl l                ; shift into position.
3016   838A CB 11              rl c
3017   838C CB 14              rl h
3018   838E 3D                 dec a               ; one less iteration.
3019   838F C2 88 83           jp nz,sprit3
3020   8392 7D                 ld a,l
3021   8393 69                 ld l,c
3022   8394 4C                 ld c,h
3023   8395 67                 ld h,a
3024   8396 C3 C1 83           jp sprit0           ; now apply to screen.
3025   8399             
3026   8399 E5          sprite push hl             ; store sprite graphic address.
3027   839A CD F4 88           call scadd          ; get screen address in hl.
3028   839D EB                 ex de,hl            ; switch to de.
3029   839E E1                 pop hl              ; restore graphic address.
3030   839F 3A 5C 77           ld a,(dispy)        ; y position.
3031   83A2 E6 07              and 7               ; position straddling cells.
3032   83A4 47                 ld b,a              ; store in b register.
3033   83A5 3E 10              ld a,16             ; pixel height.
3034   83A7 08          sprit1 ex af,af'
3035   83A8 4E                 ld c,(hl)           ; fetch first byte.
3036   83A9 23                 inc hl              ; next byte.
3037   83AA E5                 push hl             ; store source address.
3038   83AB 6E                 ld l,(hl)
3039   83AC 26 00              ld h,0
3040   83AE 78                 ld a,b              ; position straddling cells.
3041   83AF A7                 and a               ; is it zero?
3042   83B0 28 0F              jr z,sprit0         ; yes, apply to screen.
3043   83B2 FE 05              cp 5
3044   83B4 30 CF              jr nc,sprit7
3045   83B6 A7                 and a               ; clear carry.
3046   83B7 CB 19       sprit2 rr c
3047   83B9 CB 1D              rr l
3048   83BB CB 1C              rr h
3049   83BD 3D                 dec a
3050   83BE C2 B7 83           jp nz,sprit2
3051   83C1 1A          sprit0 ld a,(de)           ; fetch screen image.
3052   83C2 A9                 xor c               ; merge with graphic.
3053   83C3 12                 ld (de),a           ; write to screen.
3054   83C4 1C                 inc e               ; next screen byte.
3055   83C5 1A                 ld a,(de)           ; fetch screen image.
3056   83C6 AD                 xor l               ; combine with graphic.
3057   83C7 12                 ld (de),a           ; write to screen.
3058   83C8 13                 inc de              ; next screen address.
3059   83C9 1A                 ld a,(de)           ; fetch screen image.
3060   83CA AC                 xor h               ; combine with graphic.
3061   83CB 12                 ld (de),a           ; write to screen.
3062   83CC 1B                 dec de              ; left to middle byte.
3063   83CD 1D                 dec e               ; back to start byte.
3064   83CE 14                 inc d               ; increment line number.
3065   83CF 7A                 ld a,d              ; segment address.
3066   83D0 E6 07              and 7               ; reached end of segment?
3067   83D2 C2 E0 83           jp nz,sprit6        ; no, just do next line within cell.
3068   83D5 7B                 ld a,e              ; low byte.
3069   83D6 C6 20              add a,32            ; look down.
3070   83D8 5F                 ld e,a              ; new address.
3071   83D9 DA E0 83           jp c,sprit6         ; done.
3072   83DC 7A                 ld a,d              ; high byte.
3073   83DD D6 08              sub 8               ; start of segment.
3074   83DF 57                 ld d,a              ; new high byte.
3075   83E0 E1          sprit6 pop hl              ; restore source address.
3076   83E1 23                 inc hl              ; next source byte.
3077   83E2 08                 ex af,af'
3078   83E3 3D                 dec a
3079   83E4 C2 A7 83           jp nz,sprit1
3080   83E7 C9                 ret
3081   83E8             
3082   83E8             ; Get room address.
3083   83E8             
3084   83E8 3A 35 77    groom  ld a,(scno)         ; screen number.
3085   83EB 11 00 00    groomx ld de,0             ; start at zero.
3086   83EE 2A 65 77           ld hl,(scrptr)      ; pointer to screens.
3087   83F1 A7                 and a               ; is it the first one?
3088   83F2 28 0A       groom1 jr z,groom0         ; no more screens to skip.
3089   83F4 4E                 ld c,(hl)           ; low byte of screen size.
3090   83F5 23                 inc hl              ; point to high byte.
3091   83F6 46                 ld b,(hl)           ; high byte of screen size.
3092   83F7 23                 inc hl              ; next address.
3093   83F8 EB                 ex de,hl            ; put total in hl, pointer in de.
3094   83F9 09                 add hl,bc           ; skip a screen.
3095   83FA EB                 ex de,hl            ; put total in de, pointer in hl.
3096   83FB 3D                 dec a               ; one less iteration.
3097   83FC 18 F4              jr groom1           ; loop until we reach the end.
3098   83FE 2A 65 77    groom0 ld hl,(scrptr)      ; pointer to screens.
3099   8401 19                 add hl,de           ; add displacement.
3100   8402 3A C7 6C           ld a,(numsc)        ; number of screens.
3101   8405 16 00              ld d,0              ; zeroise high byte.
3102   8407 5F                 ld e,a              ; displacement in de.
3103   8408 19                 add hl,de           ; add double displacement to address.
3104   8409 19                 add hl,de
3105   840A C9                 ret
3106   840B             
3107   840B             ; Draw present room.
3108   840B             
3109   840B 3A 2C 77    droom  ld a,(wintop)       ; window top.
3110   840E 32 5B 77           ld (dispx),a        ; set x coordinate.
3111   8411 2A 5F 77    droom2 ld hl,(blkptr)      ; blocks.
3112   8414 22 2E 82           ld (grbase),hl      ; set graphics base.
3113   8417 CD E8 83           call groom          ; get address of current room.
3114   841A AF                 xor a               ; zero in accumulator.
3115   841B 32 5F 84           ld (comcnt),a       ; reset compression counter.
3116   841E 3A 2E 77           ld a,(winhgt)       ; height of window.
3117   8421 F5          droom0 push af             ; store row counter.
3118   8422 3A 2D 77           ld a,(winlft)       ; window left edge.
3119   8425 32 5C 77           ld (dispy),a        ; set cursor position.
3120   8428 3A 2F 77           ld a,(winwid)       ; width of window.
3121   842B F5          droom1 push af             ; store column counter.
3122   842C CD 44 84           call flbyt          ; decompress next byte on the fly.
3123   842F E5                 push hl             ; store address of cell.
3124   8430 CD 58 83           call pattr          ; show attributes and block.
3125   8433 E1                 pop hl              ; restore cell address.
3126   8434 F1                 pop af              ; restore loop counter.
3127   8435 3D                 dec a               ; one less column.
3128   8436 20 F3              jr nz,droom1        ; repeat for entire line.
3129   8438 3A 5B 77           ld a,(dispx)        ; x coord.
3130   843B 3C                 inc a               ; move down one line.
3131   843C 32 5B 77           ld (dispx),a        ; set new position.
3132   843F F1                 pop af              ; restore row counter.
3133   8440 3D                 dec a               ; one less row.
3134   8441 20 DE              jr nz,droom0        ; repeat for all rows.
3135   8443 C9                 ret
3136   8444             
3137   8444             ; Decompress bytes on-the-fly.
3138   8444             
3139   8444 3A 5F 84    flbyt  ld a,(comcnt)       ; compression counter.
3140   8447 A7                 and a               ; any more to decompress?
3141   8448 20 0C              jr nz,flbyt1        ; yes.
3142   844A 7E                 ld a,(hl)           ; fetch next byte.
3143   844B 23                 inc hl              ; point to next cell.
3144   844C FE FF              cp 255              ; is this byte a control code?
3145   844E C0                 ret nz              ; no, this byte is uncompressed.
3146   844F 7E                 ld a,(hl)           ; fetch byte type.
3147   8450 32 5E 84           ld (combyt),a       ; set up the type.
3148   8453 23                 inc hl              ; point to quantity.
3149   8454 7E                 ld a,(hl)           ; get quantity.
3150   8455 23                 inc hl              ; point to next byte.
3151   8456 3D          flbyt1 dec a               ; one less.
3152   8457 32 5F 84           ld (comcnt),a       ; store new quantity.
3153   845A 3A 5E 84           ld a,(combyt)       ; byte to expand.
3154   845D C9                 ret
3155   845E             
3156   845E             
3157   845E 00          combyt defb 0              ; byte type compressed.
3158   845F 00          comcnt defb 0              ; compression counter.
3159   8460             
3160   8460             ; Ladder down check.
3161   8460             
3162   8460 DD 7E 08    laddd  ld a,(ix+8)         ; x coordinate.
3163   8463 E6 FE              and 254             ; make it even.
3164   8465 DD 77 08           ld (ix+8),a         ; reset it.
3165   8468 DD 66 09           ld h,(ix+9)         ; y coordinate.
3166   846B C6 10       numsp5 add a,16            ; look down 16 pixels.
3167   846D 6F                 ld l,a              ; coords in hl.
3168   846E 18 0E              jr laddv
3169   8470             
3170   8470             ; Ladder up check.
3171   8470             
3172   8470 DD 7E 08    laddu  ld a,(ix+8)         ; x coordinate.
3173   8473 E6 FE              and 254             ; make it even.
3174   8475 DD 77 08           ld (ix+8),a         ; reset it.
3175   8478 DD 66 09           ld h,(ix+9)         ; y coordinate.
3176   847B C6 0E       numsp6 add a,14            ; look 2 pixels above feet.
3177   847D 6F                 ld l,a              ; coords in hl.
3178   847E 22 5B 77    laddv  ld (dispx),hl       ; set up test coordinates.
3179   8481 CD E7 85           call tstbl          ; get map address.
3180   8484 CD 35 85           call ldchk          ; standard ladder check.
3181   8487 C0                 ret nz              ; no way through.
3182   8488 23                 inc hl              ; look right one cell.
3183   8489 CD 35 85           call ldchk          ; do the check.
3184   848C C0                 ret nz              ; impassable.
3185   848D 3A 5C 77           ld a,(dispy)        ; y coordinate.
3186   8490 E6 07              and 7               ; position straddling block cells.
3187   8492 C8                 ret z               ; no more checks needed.
3188   8493 23                 inc hl              ; look to third cell.
3189   8494 CD 35 85           call ldchk          ; do the check.
3190   8497 C9                 ret                 ; return with zero flag set accordingly.
3191   8498             
3192   8498             ; Can go up check.
3193   8498             
3194   8498 DD 7E 08    cangu  ld a,(ix+8)         ; x coordinate.
3195   849B DD 66 09           ld h,(ix+9)         ; y coordinate.
3196   849E D6 02              sub 2               ; look up 2 pixels.
3197   84A0 6F                 ld l,a              ; coords in hl.
3198   84A1 22 5B 77           ld (dispx),hl       ; set up test coordinates.
3199   84A4 CD E7 85           call tstbl          ; get map address.
3200   84A7 CD 0B 85           call lrchk          ; standard left/right check.
3201   84AA C0                 ret nz              ; no way through.
3202   84AB 23                 inc hl              ; look right one cell.
3203   84AC CD 0B 85           call lrchk          ; do the check.
3204   84AF C0                 ret nz              ; impassable.
3205   84B0 3A 5C 77           ld a,(dispy)        ; y coordinate.
3206   84B3 E6 07              and 7               ; position straddling block cells.
3207   84B5 C8                 ret z               ; no more checks needed.
3208   84B6 23                 inc hl              ; look to third cell.
3209   84B7 CD 0B 85           call lrchk          ; do the check.
3210   84BA C9                 ret                 ; return with zero flag set accordingly.
3211   84BB             
3212   84BB             ; Can go down check.
3213   84BB             
3214   84BB DD 7E 08    cangd  ld a,(ix+8)         ; x coordinate.
3215   84BE DD 66 09           ld h,(ix+9)         ; y coordinate.
3216   84C1 C6 10       numsp3 add a,16            ; look down 16 pixels.
3217   84C3 6F                 ld l,a              ; coords in hl.
3218   84C4 22 5B 77           ld (dispx),hl       ; set up test coordinates.
3219   84C7 CD E7 85           call tstbl          ; get map address.
3220   84CA CD 19 85           call plchk          ; block, platform check.
3221   84CD C0                 ret nz              ; no way through.
3222   84CE 23                 inc hl              ; look right one cell.
3223   84CF CD 19 85           call plchk          ; block, platform check.
3224   84D2 C0                 ret nz              ; impassable.
3225   84D3 3A 5C 77           ld a,(dispy)        ; y coordinate.
3226   84D6 E6 07              and 7               ; position straddling block cells.
3227   84D8 C8                 ret z               ; no more checks needed.
3228   84D9 23                 inc hl              ; look to third cell.
3229   84DA CD 19 85           call plchk          ; block, platform check.
3230   84DD C9                 ret                 ; return with zero flag set accordingly.
3231   84DE             
3232   84DE             ; Can go left check.
3233   84DE             
3234   84DE DD 6E 08    cangl  ld l,(ix+8)         ; x coordinate.
3235   84E1 DD 7E 09           ld a,(ix+9)         ; y coordinate.
3236   84E4 D6 02              sub 2               ; look left 2 pixels.
3237   84E6 67                 ld h,a              ; coords in hl.
3238   84E7 18 09              jr cangh            ; test if we can go there.
3239   84E9             
3240   84E9             ; Can go right check.
3241   84E9             
3242   84E9 DD 6E 08    cangr  ld l,(ix+8)         ; x coordinate.
3243   84EC DD 7E 09           ld a,(ix+9)         ; y coordinate.
3244   84EF C6 10              add a,16            ; look right 16 pixels.
3245   84F1 67                 ld h,a              ; coords in hl.
3246   84F2             
3247   84F2 22 5B 77    cangh  ld (dispx),hl       ; set up test coordinates.
3248   84F5 06 03       cangh2 ld b,3              ; default rows to write.
3249   84F7 7D                 ld a,l              ; x position.
3250   84F8 E6 07              and 7               ; does x straddle cells?
3251   84FA 20 01              jr nz,cangh0        ; yes, loop counter is good.
3252   84FC 05                 dec b               ; one less row to write.
3253   84FD CD E7 85    cangh0 call tstbl          ; get map address.
3254   8500 11 20 00           ld de,32            ; distance to next cell.
3255   8503 CD 0B 85    cangh1 call lrchk          ; standard left/right check.
3256   8506 C0                 ret nz              ; no way through.
3257   8507 19                 add hl,de           ; look down.
3258   8508 10 F9              djnz cangh1
3259   850A C9                 ret
3260   850B             
3261   850B             ; Check left/right movement is okay.
3262   850B             
3263   850B 7E          lrchk  ld a,(hl)           ; fetch map cell.
3264   850C FE 02              cp WALL             ; is it passable?
3265   850E 28 06              jr z,lrchkx         ; no.
3266   8510 FE 04              cp FODDER           ; fodder has to be dug.
3267   8512 28 02              jr z,lrchkx         ; not passable.
3268   8514 AF          always xor a               ; report it as okay.
3269   8515 C9                 ret
3270   8516 AF          lrchkx xor a               ; reset all bits.
3271   8517 3C                 inc a
3272   8518 C9                 ret
3273   8519             
3274   8519             ; Check platform or solid item is not in way.
3275   8519             
3276   8519 7E          plchk  ld a,(hl)           ; fetch map cell.
3277   851A FE 02              cp WALL             ; is it passable?
3278   851C 28 F8              jr z,lrchkx         ; no.
3279   851E FE 04              cp FODDER           ; fodder has to be dug.
3280   8520 28 F4              jr z,lrchkx         ; not passable.
3281   8522 FE 01              cp PLATFM           ; platform is solid.
3282   8524 28 06              jr z,plchkx         ; not passable.
3283   8526 FE 03              cp LADDER           ; is it a ladder?
3284   8528 28 EC              jr z,lrchkx         ; on ladder, deny movement.
3285   852A AF          plchk0 xor a               ; report it as okay.
3286   852B C9                 ret
3287   852C 3A 5B 77    plchkx ld a,(dispx)        ; x coordinate.
3288   852F E6 07              and 7               ; position straddling blocks.
3289   8531 28 E3              jr z,lrchkx         ; on platform, deny movement.
3290   8533 18 F5              jr plchk0
3291   8535             
3292   8535             ; Check ladder is available.
3293   8535             
3294   8535 7E          ldchk  ld a,(hl)           ; fetch cell.
3295   8536 FE 03              cp LADDER           ; is it a ladder?
3296   8538 C9                 ret                 ; return with zero flag set accordingly.
3297   8539             
3298   8539             ; Get collectables.
3299   8539             
3300   8539 06 08       getcol ld b,COLECT         ; collectable blocks.
3301   853B CD 9F 85           call tded           ; test for collectable blocks.
3302   853E B8                 cp b                ; did we find one?
3303   853F C0                 ret nz              ; none were found, job done.
3304   8540 CD 48 85           call gtblk          ; get block.
3305   8543 CD 8A 66           call evnt20         ; collected block event.
3306   8546 18 F1              jr getcol           ; repeat until none left.
3307   8548             
3308   8548             ; Get collectable block.
3309   8548             
3310   8548 36 00       gtblk  ld (hl),0           ; make it empty now.
3311   854A 11 00 FD           ld de,MAP           ; map address.
3312   854D A7                 and a               ; clear carry.
3313   854E ED 52              sbc hl,de           ; find cell number.
3314   8550 7D                 ld a,l              ; get low byte of cell number.
3315   8551 E6 1F              and 31              ; 0 - 31 is column.
3316   8553 57                 ld d,a              ; store y in d register.
3317   8554 29                 add hl,hl           ; multiply by 8.
3318   8555 29                 add hl,hl
3319   8556 29                 add hl,hl           ; x is now in h.
3320   8557 5C                 ld e,h              ; put x in e.
3321   8558 ED 53 5B 77        ld (dispx),de       ; set display coordinates.
3322   855C             
3323   855C 3A 57 83           ld a,(colpat)       ; get collectable block used on this screen.
3324   855F 07                 rlca                ; multiply char by 8.
3325   8560 07                 rlca
3326   8561 07                 rlca
3327   8562 5F                 ld e,a              ; store shift in e.
3328   8563 E6 07              and 7               ; only want high byte bits.
3329   8565 57                 ld d,a              ; store in d.
3330   8566 7B                 ld a,e              ; restore shifted value.
3331   8567 E6 F8              and 248             ; only want low byte bits.
3332   8569 5F                 ld e,a              ; that's the low byte.
3333   856A 21 C8 6C           ld hl,chgfx         ; address of graphics.
3334   856D 19                 add hl,de           ; add displacement.
3335   856E CD E0 82           call gprad          ; get screen address.
3336   8571             
3337   8571 1A                 ld a,(de)           ; get image byte.
3338   8572 AE                 xor (hl)            ; merge with screen image.
3339   8573 12                 ld (de),a           ; copy to screen.
3340   8574 23                 inc hl              ; next image byte.
3341   8575 14                 inc d               ; next screen row down.
3342   8576 1A                 ld a,(de)           ; get image byte.
3343   8577 AE                 xor (hl)            ; merge with screen image.
3344   8578 12                 ld (de),a           ; copy to screen.
3345   8579 23                 inc hl              ; next image byte.
3346   857A 14                 inc d               ; next screen row down.
3347   857B 1A                 ld a,(de)           ; get image byte.
3348   857C AE                 xor (hl)            ; merge with screen image.
3349   857D 12                 ld (de),a           ; copy to screen.
3350   857E 23                 inc hl              ; next image byte.
3351   857F 14                 inc d               ; next screen row down.
3352   8580 1A                 ld a,(de)           ; get image byte.
3353   8581 AE                 xor (hl)            ; merge with screen image.
3354   8582 12                 ld (de),a           ; copy to screen.
3355   8583 23                 inc hl              ; next image byte.
3356   8584 14                 inc d               ; next screen row down.
3357   8585 1A                 ld a,(de)           ; get image byte.
3358   8586 AE                 xor (hl)            ; merge with screen image.
3359   8587 12                 ld (de),a           ; copy to screen.
3360   8588 23                 inc hl              ; next image byte.
3361   8589 14                 inc d               ; next screen row down.
3362   858A 1A                 ld a,(de)           ; get image byte.
3363   858B AE                 xor (hl)            ; merge with screen image.
3364   858C 12                 ld (de),a           ; copy to screen.
3365   858D 23                 inc hl              ; next image byte.
3366   858E 14                 inc d               ; next screen row down.
3367   858F 1A                 ld a,(de)           ; get image byte.
3368   8590 AE                 xor (hl)            ; merge with screen image.
3369   8591 12                 ld (de),a           ; copy to screen.
3370   8592 23                 inc hl              ; next image byte.
3371   8593 14                 inc d               ; next screen row down.
3372   8594 1A                 ld a,(de)           ; get image byte.
3373   8595 AE                 xor (hl)            ; merge with screen image.
3374   8596 12                 ld (de),a           ; copy to screen.
3375   8597 CD 0E 83           call gaadd          ; get attribute address for block.
3376   859A 3A F0 6C           ld a,(bcol)         ; first block colour.
3377   859D 77                 ld (hl),a           ; set block attribute.
3378   859E C9                 ret
3379   859F             
3380   859F             ; Touched deadly block check.
3381   859F             ; Returns with DEADLY (must be non-zero) in accumulator if true.
3382   859F             
3383   859F DD 6E 08    tded   ld l,(ix+8)         ; x coordinate.
3384   85A2 DD 66 09           ld h,(ix+9)         ; y coordinate.
3385   85A5 22 5B 77           ld (dispx),hl       ; set up test coordinates.
3386   85A8 CD E7 85           call tstbl          ; get map address.
3387   85AB 11 1F 00           ld de,31            ; default distance to next line down.
3388   85AE B8                 cp b                ; is this the required block?
3389   85AF C8                 ret z               ; yes.
3390   85B0 23                 inc hl              ; next cell.
3391   85B1 7E                 ld a,(hl)           ; fetch type.
3392   85B2 B8                 cp b                ; is this deadly/custom?
3393   85B3 C8                 ret z               ; yes.
3394   85B4 3A 5C 77           ld a,(dispy)        ; horizontal position.
3395   85B7 4F                 ld c,a              ; store column in c register.
3396   85B8 E6 07              and 7               ; is it straddling cells?
3397   85BA 28 05              jr z,tded0          ; no.
3398   85BC 23                 inc hl              ; last cell.
3399   85BD 7E                 ld a,(hl)           ; fetch type.
3400   85BE B8                 cp b                ; is this the block?
3401   85BF C8                 ret z               ; yes.
3402   85C0 1B                 dec de              ; one less cell to next row down.
3403   85C1 19          tded0  add hl,de           ; point to next row.
3404   85C2 7E                 ld a,(hl)           ; fetch left cell block.
3405   85C3 B8                 cp b                ; is this fatal?
3406   85C4 C8                 ret z               ; yes.
3407   85C5 23                 inc hl              ; next cell.
3408   85C6 7E                 ld a,(hl)           ; fetch type.
3409   85C7 B8                 cp b                ; is this fatal?
3410   85C8 C8                 ret z               ; yes.
3411   85C9 79                 ld a,c              ; horizontal position.
3412   85CA E6 07              and 7               ; is it straddling cells?
3413   85CC 28 04              jr z,tded1          ; no.
3414   85CE 23                 inc hl              ; last cell.
3415   85CF 7E                 ld a,(hl)           ; fetch type.
3416   85D0 B8                 cp b                ; is this fatal?
3417   85D1 C8                 ret z               ; yes.
3418   85D2 3A 5B 77    tded1  ld a,(dispx)        ; vertical position.
3419   85D5 E6 07              and 7               ; is it straddling cells?
3420   85D7 C8                 ret z               ; no, job done.
3421   85D8 19                 add hl,de           ; point to next row.
3422   85D9 7E                 ld a,(hl)           ; fetch left cell block.
3423   85DA B8                 cp b                ; is this fatal?
3424   85DB C8                 ret z               ; yes.
3425   85DC 23                 inc hl              ; next cell.
3426   85DD 7E                 ld a,(hl)           ; fetch type.
3427   85DE B8                 cp b                ; is this fatal?
3428   85DF C8                 ret z               ; yes.
3429   85E0 79                 ld a,c              ; horizontal position.
3430   85E1 E6 07              and 7               ; is it straddling cells?
3431   85E3 C8                 ret z               ; no.
3432   85E4 23                 inc hl              ; last cell.
3433   85E5 7E                 ld a,(hl)           ; fetch final type.
3434   85E6 C9                 ret                 ; return with final type in accumulator.
3435   85E7             
3436   85E7             
3437   85E7             ; Fetch block type at (dispx, dispy).
3438   85E7             
3439   85E7 3A 5B 77    tstbl  ld a,(dispx)        ; fetch x coord.
3440   85EA 07                 rlca                ; divide by 8,
3441   85EB 07                 rlca                ; and multiply by 32.
3442   85EC 57                 ld d,a              ; store in d.
3443   85ED E6 E0              and 224             ; mask off high bits.
3444   85EF 5F                 ld e,a              ; low byte.
3445   85F0 7A                 ld a,d              ; restore shift result.
3446   85F1 E6 03              and 3               ; high bits.
3447   85F3 57                 ld d,a              ; got displacement in de.
3448   85F4 3A 5C 77           ld a,(dispy)        ; y coord.
3449   85F7 1F                 rra                 ; divide by 8.
3450   85F8 1F                 rra
3451   85F9 1F                 rra
3452   85FA E6 1F              and 31              ; only want 0 - 31.
3453   85FC 83                 add a,e             ; add to displacement.
3454   85FD 5F                 ld e,a              ; displacement in de.
3455   85FE 21 00 FD           ld hl,MAP           ; position of dummy screen.
3456   8601 19                 add hl,de           ; point to address.
3457   8602 7E                 ld a,(hl)           ; fetch byte there.
3458   8603 C9                 ret
3459   8604             
3460   8604             ; Jump - if we can.
3461   8604             ; Requires initial speed to be set up in accumulator prior to call.
3462   8604             
3463   8604 ED 44       jump   neg                 ; switch sign so we jump up.
3464   8606 4F                 ld c,a              ; store in c register.
3465   8607             ;       ld a,(ix+8)         ; x coordinate.
3466   8607             ;       ld h,(ix+9)         ; y coordinate.
3467   8607             ;numsp4 add a,16            ; look down 16 pixels.
3468   8607             ;       ld l,a              ; coords in hl.
3469   8607             ;       and 7               ; are we on platform boundary?
3470   8607             ;       ret nz              ; no, cannot jump.
3471   8607             ;       ld (dispx),hl       ; set up test coordinates.
3472   8607             ;       ld b,a              ; copy to b register.
3473   8607             ;       call tstbl          ; get map address.
3474   8607             ;       call plchk          ; block, platform check.
3475   8607             ;       jr nz,jump0         ; it's solid, we can jump.
3476   8607             ;       inc hl              ; look right one cell.
3477   8607             ;       call plchk          ; block, platform check.
3478   8607             ;       jr nz,jump0         ; it's solid, we can jump.
3479   8607             ;       ld a,b              ; y coordinate.
3480   8607             ;       and 7               ; position straddling block cells.
3481   8607             ;       ret z               ; no more checks needed.
3482   8607             ;       inc hl              ; look to third cell.
3483   8607             ;       call plchk          ; block, platform check.
3484   8607             ;       ret z               ; not solid, don't jump.
3485   8607 DD 7E 0D    jump0  ld a,(ix+13)        ; jumping flag.
3486   860A A7                 and a               ; is it set?
3487   860B C0                 ret nz              ; already in the air.
3488   860C DD 34 0D           inc (ix+13)         ; set it.
3489   860F DD 71 0E           ld (ix+14),c        ; set jump height.
3490   8612 C9                 ret
3491   8613             
3492   8613 DD 7E 0D    hop    ld a,(ix+13)        ; jumping flag.
3493   8616 A7                 and a               ; is it set?
3494   8617 C0                 ret nz              ; already in the air.
3495   8618 DD 36 0D FF        ld (ix+13),255      ; set it.
3496   861C DD 36 0E 00        ld (ix+14),0        ; set jump table displacement.
3497   8620 C9                 ret
3498   8621             
3499   8621             ; Random numbers code.
3500   8621             ; Pseudo-random number generator, 8-bit.
3501   8621             
3502   8621 21 1B 82    random ld hl,seed          ; set up seed pointer.
3503   8624 7E                 ld a,(hl)           ; get last random number.
3504   8625 47                 ld b,a              ; copy to b register.
3505   8626 0F                 rrca                ; multiply by 32.
3506   8627 0F                 rrca
3507   8628 0F                 rrca
3508   8629 EE 1F              xor 31
3509   862B 80                 add a,b
3510   862C DE FF              sbc a,255
3511   862E 77                 ld (hl),a           ; store new seed.
3512   862F 32 53 77           ld (varrnd),a       ; return number in variable.
3513   8632 C9                 ret
3514   8633             
3515   8633             
3516   8633             ; Keyboard test routine.
3517   8633             
3518   8633 4F          ktest  ld c,a              ; key to test in c.
3519   8634 E6 07              and 7               ; mask bits d0-d2 for row.
3520   8636 3C                 inc a               ; in range 1-8.
3521   8637 47                 ld b,a              ; place in b.
3522   8638 CB 39              srl c               ; divide c by 8
3523   863A CB 39              srl c               ; to find position within row.
3524   863C CB 39              srl c
3525   863E 3E 05              ld a,5              ; only 5 keys per row.
3526   8640 91                 sub c               ; subtract position.
3527   8641 4F                 ld c,a              ; put in c.
3528   8642 3E FE              ld a,254            ; high byte of port to read.
3529   8644 0F          ktest0 rrca                ; rotate into position.
3530   8645 10 FD              djnz ktest0         ; repeat until we've found relevant row.
3531   8647 DB FE              in a,(254)          ; read port (a=high, 254=low).
3532   8649 1F          ktest1 rra                 ; rotate bit out of result.
3533   864A 0D                 dec c               ; loop counter.
3534   864B C2 49 86           jp nz,ktest1        ; repeat until bit for position in carry.
3535   864E C9                 ret
3536   864F             
3537   864F             
3538   864F             ; Joystick and keyboard reading routines.
3539   864F             
3540   864F 3A 4F 77    joykey ld a,(contrl)       ; control flag.
3541   8652 3D                 dec a               ; is it the keyboard?
3542   8653 28 18              jr z,joyjoy         ; no, it's Kempston joystick.
3543   8655 3D                 dec a               ; Sinclair?
3544   8656 28 34              jr z,joysin         ; read Sinclair joystick.
3545   8658             
3546   8658             ; Keyboard controls.
3547   8658             
3548   8658 21 B8 76           ld hl,keys+6        ; address of last key.
3549   865B 1E 00              ld e,0              ; zero reading.
3550   865D 16 07              ld d,7              ; keys to read.
3551   865F 7E          joyke0 ld a,(hl)           ; get key from table.
3552   8660 CD 33 86           call ktest          ; being pressed?
3553   8663 3F                 ccf                 ; complement the carry.
3554   8664 CB 13              rl e                ; rotate into reading.
3555   8666 2B                 dec hl              ; next key.
3556   8667 15                 dec d               ; one less to do.
3557   8668 C2 5F 86           jp nz,joyke0        ; repeat for all keys.
3558   866B 18 1A              jr joyjo1           ; store the value.
3559   866D             
3560   866D             ; Kempston joystick controls.
3561   866D             
3562   866D 01 1F 00    joyjoy ld bc,31            ; port for Kempston interface.
3563   8670 ED 78              in a,(c)            ; read it.
3564   8672 5F          joyjo3 ld e,a              ; copy to e register.
3565   8673 3A B7 76           ld a,(keys+5)       ; key six.
3566   8676 CD 33 86           call ktest          ; being pressed?
3567   8679 38 02              jr c,joyjo0         ; not pressed.
3568   867B CB EB              set 5,e             ; set bit d5.
3569   867D 3A B8 76    joyjo0 ld a,(keys+6)       ; key seven.
3570   8680 CD 33 86           call ktest          ; being pressed?
3571   8683 38 02              jr c,joyjo1         ; not pressed.
3572   8685 CB F3              set 6,e             ; set bit d6.
3573   8687 7B          joyjo1 ld a,e              ; copy e register to accumulator.
3574   8688 32 2A 77    joyjo2 ld (joyval),a       ; remember value.
3575   868B C9                 ret
3576   868C             
3577   868C             ; Sinclair joystick controls.
3578   868C             
3579   868C 01 FE EF    joysin ld bc,61438         ; port for Sinclair 2.
3580   868F ED 78              in a,(c)            ; read joystick.
3581   8691 57                 ld d,a              ; clear values.
3582   8692 AF                 xor a               ; clear accumulator.
3583   8693 1E 10              ld e,16             ; Kempston fire bit value.
3584   8695 CB 42              bit 0,d             ; fire bit pressed?
3585   8697 CC B8 86           call z,joysi0       ; add bit.
3586   869A 1E 01              ld e,1              ; Kempston bit value.
3587   869C CB 5A              bit 3,d             ; fire bit pressed?
3588   869E CC B8 86           call z,joysi0       ; add bit.
3589   86A1 1E 02              ld e,2              ; Kempston bit value.
3590   86A3 CB 62              bit 4,d             ; fire bit pressed?
3591   86A5 CC B8 86           call z,joysi0       ; add bit.
3592   86A8 1E 08              ld e,8              ; Kempston bit value.
3593   86AA CB 4A              bit 1,d             ; fire bit pressed?
3594   86AC CC B8 86           call z,joysi0       ; add bit.
3595   86AF 1E 04              ld e,4              ; Kempston bit value.
3596   86B1 CB 52              bit 2,d             ; fire bit pressed?
3597   86B3 CC B8 86           call z,joysi0       ; add bit.
3598   86B6 18 BA              jr joyjo3           ; read last 2 keys a la Kempston.
3599   86B8             
3600   86B8 83          joysi0 add a,e             ; add bit value.
3601   86B9 C9                 ret
3602   86BA             
3603   86BA             ; Display message.
3604   86BA             
3605   86BA             ;dmsg   ld hl,nummsg        ; total messages.
3606   86BA             ;       cp (hl)             ; does this one exist?
3607   86BA             ;       ret nc              ; no, nothing to display.
3608   86BA 21 91 66    dmsg   ld hl,msgdat        ; pointer to messages.
3609   86BD CD A4 87           call getwrd         ; get message number.
3610   86C0 CD 93 87    dmsg3  call preprt         ; pre-printing stuff.
3611   86C3 CD 30 82           call checkx         ; make sure we're in a printable range.
3612   86C6 3A 00 87           ld a,(prtmod)       ; print mode.
3613   86C9 A7                 and a               ; standard size?
3614   86CA C2 01 87           jp nz,bmsg1         ; no, double-height text.
3615   86CD E5          dmsg0  push hl             ; store string pointer.
3616   86CE 7E                 ld a,(hl)           ; fetch byte to display.
3617   86CF E6 7F              and 127             ; remove any end marker.
3618   86D1 FE 0D              cp 13               ; newline character?
3619   86D3 28 1B              jr z,dmsg1
3620   86D5 CD 26 83           call pchar          ; display character.
3621   86D8 CD 0E 83           call gaadd          ; get attribute address.
3622   86DB 3A 8D 5C           ld a,(23693)        ; current cell colours.
3623   86DE 77                 ld (hl),a           ; write to attribute cell.
3624   86DF CD 81 87           call nexpos         ; display position.
3625   86E2 20 03              jr nz,dmsg2         ; not on a new line.
3626   86E4 CD 8B 87           call nexlin         ; next line down.
3627   86E7 E1          dmsg2  pop hl
3628   86E8 7E                 ld a,(hl)           ; fetch last character.
3629   86E9 17                 rla                 ; was it the end?
3630   86EA DA 5F 82           jp c,dscor2         ; yes, job done.
3631   86ED 23                 inc hl              ; next character to display.
3632   86EE 18 DD              jr dmsg0
3633   86F0 21 5B 77    dmsg1  ld hl,dispx         ; x coordinate.
3634   86F3 34                 inc (hl)            ; newline.
3635   86F4 7E                 ld a,(hl)           ; fetch position.
3636   86F5 FE 18              cp 24               ; past screen edge?
3637   86F7 38 02              jr c,dmsg4          ; no, it's okay.
3638   86F9 36 00              ld (hl),0           ; restart at top.
3639   86FB 23          dmsg4  inc hl              ; y coordinate.
3640   86FC 36 00              ld (hl),0           ; carriage return.
3641   86FE 18 E7              jr dmsg2
3642   8700 00          prtmod defb 0              ; print mode, 0 = standard, 1 = double-height.
3643   8701             
3644   8701             ; Display message in big text.
3645   8701             
3646   8701 7E          bmsg1  ld a,(hl)           ; get character to display.
3647   8702 E5                 push hl             ; store pointer to message.
3648   8703 E6 7F              and 127             ; only want 7 bits.
3649   8705 FE 0D              cp 13               ; newline character?
3650   8707 28 0A              jr z,bmsg2
3651   8709 CD 24 87           call bchar          ; display big char.
3652   870C E1          bmsg3  pop hl              ; retrieve message pointer.
3653   870D 7E                 ld a,(hl)           ; look at last character.
3654   870E 23                 inc hl              ; next character in list.
3655   870F 17                 rla                 ; was terminator flag set?
3656   8710 30 EF              jr nc,bmsg1         ; no, keep going.
3657   8712 C9                 ret
3658   8713 21 50 77    bmsg2  ld hl,charx         ; x coordinate.
3659   8716 34                 inc (hl)            ; newline.
3660   8717 34                 inc (hl)            ; newline.
3661   8718 7E                 ld a,(hl)           ; fetch position.
3662   8719 FE 17              cp 23               ; past screen edge?
3663   871B 38 EF              jr c,bmsg3          ; no, it's okay.
3664   871D 36 00              ld (hl),0           ; restart at top.
3665   871F 23                 inc hl              ; y coordinate.
3666   8720 36 00              ld (hl),0           ; carriage return.
3667   8722 18 E8              jr bmsg3
3668   8724             
3669   8724             
3670   8724             ; Big character display.
3671   8724             
3672   8724 07          bchar  rlca                ; multiply char by 8.
3673   8725 07                 rlca
3674   8726 07                 rlca
3675   8727 5F                 ld e,a              ; store shift in e.
3676   8728 E6 07              and 7               ; only want high byte bits.
3677   872A 57                 ld d,a              ; store in d.
3678   872B 7B                 ld a,e              ; restore shifted value.
3679   872C E6 F8              and 248             ; only want low byte bits.
3680   872E 5F                 ld e,a              ; that's the low byte.
3681   872F 2A 36 5C           ld hl,(23606)       ; address of font.
3682   8732 19                 add hl,de           ; add displacement.
3683   8733 CD E0 82           call gprad          ; get screen address.
3684   8736 EB                 ex de,hl            ; font in de, screen address in hl.
3685   8737 06 08              ld b,8              ; height of character in font.
3686   8739 1A          bchar0 ld a,(de)           ; get a bit of the font.
3687   873A 13                 inc de              ; next line of font.
3688   873B 77                 ld (hl),a           ; write to screen.
3689   873C 24                 inc h               ; down a line.
3690   873D 77                 ld (hl),a           ; write to screen.
3691   873E CD BA 89           call nline          ; next line down.
3692   8741 10 F6              djnz bchar0         ; repeat.
3693   8743 CD 0E 83           call gaadd          ; get attribute address.
3694   8746 3A 8D 5C           ld a,(23693)        ; current colour.
3695   8749 77                 ld (hl),a           ; set attribute.
3696   874A 4F                 ld c,a              ; copy colour to c.
3697   874B 11 20 00           ld de,32            ; distance to next line.
3698   874E 19                 add hl,de           ; point to second cell.
3699   874F 7C                 ld a,h              ; high byte of address.
3700   8750 FE 5B              cp 91               ; past edge of screen?
3701   8752 30 01              jr nc,bchar1        ; yes, don't write to printer buffer/sysvars.
3702   8754 71                 ld (hl),c           ; set second cell's attributes.
3703   8755 CD 81 87    bchar1 call nexpos         ; display position.
3704   8758 C2 5F 87           jp nz,bchar2        ; not on a new line.
3705   875B 34          bchar3 inc (hl)            ; newline.
3706   875C CD 8B 87           call nexlin         ; next line check.
3707   875F C3 5F 82    bchar2 jp dscor2           ; tidy up line and column variables.
3708   8762             
3709   8762             ; Display a character.
3710   8762             
3711   8762 47          achar  ld b,a              ; copy to b.
3712   8763 CD 93 87           call preprt         ; get ready to print.
3713   8766 3A 00 87           ld a,(prtmod)       ; print mode.
3714   8769 A7                 and a               ; standard size?
3715   876A 78                 ld a,b              ; character in accumulator.
3716   876B C2 24 87           jp nz,bchar         ; no, double-height text.
3717   876E CD 26 83           call pchar          ; display character.
3718   8771 CD 0E 83           call gaadd          ; get attribute address.
3719   8774 3A 8D 5C           ld a,(23693)        ; current cell colours.
3720   8777 77                 ld (hl),a           ; write to attribute cell.
3721   8778 CD 81 87           call nexpos         ; display position.
3722   877B CA 5B 87           jp z,bchar3         ; next line down.
3723   877E C3 5F 87           jp bchar2           ; tidy up.
3724   8781             
3725   8781             ; Get next print column position.
3726   8781             
3727   8781 21 5C 77    nexpos ld hl,dispy         ; display position.
3728   8784 7E                 ld a,(hl)           ; get coordinate.
3729   8785 3C                 inc a               ; move along one position.
3730   8786 E6 1F              and 31              ; reached edge of screen?
3731   8788 77                 ld (hl),a           ; set new position.
3732   8789 2B                 dec hl              ; point to x now.
3733   878A C9                 ret                 ; return with status in zero flag.
3734   878B             
3735   878B             ; Get next print line position.
3736   878B             
3737   878B 34          nexlin inc (hl)            ; newline.
3738   878C 7E                 ld a,(hl)           ; vertical position.
3739   878D FE 18              cp 24               ; past screen edge?
3740   878F D8                 ret c               ; no, still okay.
3741   8790 36 00              ld (hl),0           ; restart at top.
3742   8792 C9                 ret
3743   8793             
3744   8793             ; Pre-print preliminaries.
3745   8793             
3746   8793 ED 5B 36 5C preprt ld de,(23606)       ; font pointer.
3747   8797 ED 53 2E 82        ld (grbase),de      ; set up graphics base.
3748   879B ED 5B 50 77 prescr ld de,(charx)       ; display coordinates.
3749   879F ED 53 5B 77        ld (dispx),de       ; set up general coordinates.
3750   87A3 C9                 ret
3751   87A4             
3752   87A4             ; On entry: hl points to word list
3753   87A4             ;           a contains word number.
3754   87A4             
3755   87A4 A7          getwrd and a               ; first word in list?
3756   87A5 C8                 ret z               ; yep, don't search.
3757   87A6 47                 ld b,a
3758   87A7 7E          getwd0 ld a,(hl)
3759   87A8 23                 inc hl
3760   87A9 FE 80              cp 128              ; found end?
3761   87AB 38 FA              jr c,getwd0         ; no, carry on.
3762   87AD 10 F8              djnz getwd0         ; until we have right number.
3763   87AF C9                 ret
3764   87B0             
3765   87B0             
3766   87B0             ; Bubble sort.
3767   87B0             
3768   87B0 06 0B       bsort  ld b,NUMSPR - 1     ; sprites to swap.
3769   87B2 DD 21 65 8D        ld ix,sprtab        ; sprite table.
3770   87B6 C5          bsort0 push bc             ; store loop counter for now.
3771   87B7             
3772   87B7 DD 7E 00           ld a,(ix+0)         ; first sprite type.
3773   87BA 3C                 inc a               ; is it switched off?
3774   87BB 28 22              jr z,swemp          ; yes, may need to switch another in here.
3775   87BD             
3776   87BD DD 7E 11           ld a,(ix+TABSIZ)    ; check next slot exists.
3777   87C0 3C                 inc a               ; is it enabled?
3778   87C1 28 08              jr z,bsort2         ; no, nothing to swap.
3779   87C3             
3780   87C3 DD 7E 14           ld a,(ix+(3+TABSIZ)); fetch next sprite's coordinate.
3781   87C6 DD BE 03           cp (ix+3)           ; compare with this x coordinate.
3782   87C9 38 09              jr c,bsort1         ; next sprite is higher - may need to switch.
3783   87CB 11 11 00    bsort2 ld de,TABSIZ        ; distance to next odd/even entry.
3784   87CE DD 19              add ix,de           ; next sprite.
3785   87D0 C1                 pop bc              ; retrieve loop counter.
3786   87D1 10 E3              djnz bsort0         ; repeat for remaining sprites.
3787   87D3 C9                 ret
3788   87D4             
3789   87D4 DD 7E 11    bsort1 ld a,(ix+TABSIZ)    ; sprite on/off flag.
3790   87D7 3C                 inc a               ; is it enabled?
3791   87D8 28 F1              jr z,bsort2         ; no, nothing to swap.
3792   87DA CD EA 87           call swspr          ; swap positions.
3793   87DD 18 EC              jr bsort2
3794   87DF             
3795   87DF DD 7E 11    swemp  ld a,(ix+TABSIZ)    ; next table entry.
3796   87E2 3C                 inc a               ; is that one on?
3797   87E3 28 E6              jr z,bsort2         ; no, nothing to swap.
3798   87E5 CD EA 87           call swspr          ; swap positions.
3799   87E8 18 E1              jr bsort2
3800   87EA             
3801   87EA             ; Swap sprites.
3802   87EA             
3803   87EA DD E5       swspr  push ix             ; table address on stack.
3804   87EC E1                 pop hl              ; pop into hl pair.
3805   87ED 54                 ld d,h              ; copy to de pair.
3806   87EE 5D                 ld e,l
3807   87EF 01 11 00           ld bc,TABSIZ        ; distance to second entry.
3808   87F2 09                 add hl,bc           ; point to second sprite entry.
3809   87F3 06 11              ld b,TABSIZ         ; bytes to swap.
3810   87F5 4E          swspr0 ld c,(hl)           ; fetch second byte.
3811   87F6 1A                 ld a,(de)           ; fetch first byte.
3812   87F7 77                 ld (hl),a           ; copy to second.
3813   87F8 79                 ld a,c              ; second byte in accumulator.
3814   87F9 12                 ld (de),a           ; copy to first sprite entry.
3815   87FA 13                 inc de              ; next byte.
3816   87FB 23                 inc hl              ; next byte.
3817   87FC 10 F7              djnz swspr0         ; swap all bytes in table entry.
3818   87FE C9                 ret
3819   87FF             
3820   87FF             
3821   87FF             ; Process sprites.
3822   87FF             
3823   87FF 06 0C       pspr   ld b,NUMSPR         ; sprites to process.
3824   8801 DD 21 65 8D        ld ix,sprtab        ; sprite table.
3825   8805 C5          pspr1  push bc             ; store loop counter for now.
3826   8806 DD 7E 00           ld a,(ix+0)         ; fetch sprite type.
3827   8809 FE 09              cp 9                ; within range of sprite types?
3828   880B DC 17 88           call c,pspr2        ; yes, process this one.
3829   880E 11 11 00           ld de,TABSIZ        ; distance to next odd/even entry.
3830   8811 DD 19              add ix,de           ; next sprite.
3831   8813 C1                 pop bc              ; retrieve loop counter.
3832   8814 10 EF              djnz pspr1          ; repeat for remaining sprites.
3833   8816 C9                 ret
3834   8817 DD 22 30 88 pspr2  ld (ogptr),ix       ; store original sprite pointer.
3835   881B CD 23 88           call pspr3          ; do the routine.
3836   881E DD 2A 30 88 rtorg  ld ix,(ogptr)       ; restore original pointer to sprite.
3837   8822 C9          rtorg0 ret
3838   8823 21 32 88    pspr3  ld hl,evtyp0        ; sprite type events list.
3839   8826 87          pspr4  add a,a             ; double accumulator.
3840   8827 5F                 ld e,a              ; copy to de.
3841   8828 16 00              ld d,0              ; no high byte.
3842   882A 19                 add hl,de           ; point to address of routine.
3843   882B 5E                 ld e,(hl)           ; address low.
3844   882C 23                 inc hl              ; next byte of address.
3845   882D 56                 ld d,(hl)           ; address high.
3846   882E EB                 ex de,hl            ; swap address into hl.
3847   882F E9                 jp (hl)             ; go there.
3848   8830 00 00       ogptr  defw 0              ; original sprite pointer.
3849   8832             
3850   8832             ; Address of each sprite type's routine.
3851   8832             
3852   8832 13 61       evtyp0 defw evnt00
3853   8834 B8 61       evtyp1 defw evnt01
3854   8836 01 63       evtyp2 defw evnt02
3855   8838 F5 63       evtyp3 defw evnt03
3856   883A F6 63       evtyp4 defw evnt04
3857   883C F7 63       evtyp5 defw evnt05
3858   883E F8 63       evtyp6 defw evnt06
3859   8840 F9 63       evtyp7 defw evnt07
3860   8842 FA 63       evtyp8 defw evnt08
3861   8844             
3862   8844             
3863   8844             ; Display sprites.
3864   8844             
3865   8844 06 06       dspr   ld b,NUMSPR/2       ; number of sprites to display.
3866   8846 C5          dspr0  push bc             ; store loop counter for now.
3867   8847 DD 7E 00           ld a,(ix+0)         ; get sprite type.
3868   884A 3C                 inc a               ; is it enabled?
3869   884B 20 21              jr nz,dspr1         ; yes, it needs deleting.
3870   884D DD 7E 05    dspr5  ld a,(ix+5)         ; new type.
3871   8850 3C                 inc a               ; is it enabled?
3872   8851 20 4E              jr nz,dspr3         ; yes, it needs drawing.
3873   8853             
3874   8853 DD E5       dspr2  push ix             ; put ix on stack.
3875   8855 E1                 pop hl              ; pop into hl.
3876   8856 5D                 ld e,l              ; copy to de.
3877   8857 54                 ld d,h
3878   8858             
3879   8858             ;dspr2  ld e,ixl            ; copy ix to de.
3880   8858             ;       ld d,ixh
3881   8858             ;       ld l,e              ; copy to hl.
3882   8858             ;       ld h,d
3883   8858 01 05 00           ld bc,5             ; distance to new type.
3884   885B 09                 add hl,bc           ; point to new properties.
3885   885C ED A0              ldi                 ; copy to old positions.
3886   885E ED A0              ldi
3887   8860 ED A0              ldi
3888   8862 ED A0              ldi
3889   8864 ED A0              ldi
3890   8866 0E 22              ld c,TABSIZ*2       ; distance to next odd/even entry.
3891   8868 DD 09              add ix,bc           ; next sprite.
3892   886A C1                 pop bc              ; retrieve loop counter.
3893   886B 10 D9              djnz dspr0          ; repeat for remaining sprites.
3894   886D C9                 ret
3895   886E             ;dspr1  ld a,(ix+3)         ; old x coord.
3896   886E             ;       cp 177              ; beyond maximum?
3897   886E             ;       jr nc,dspr5         ; yes, don't delete it.
3898   886E DD 7E 05    dspr1  ld a,(ix+5)         ; type of new sprite.
3899   8871 3C                 inc a               ; is this enabled?
3900   8872 20 06              jr nz,dspr4         ; yes, display both.
3901   8874 CD 11 89    dspr6  call sspria         ; show single sprite.
3902   8877 C3 53 88           jp dspr2
3903   887A             
3904   887A             ; Displaying two sprites.  Don't bother redrawing if nothing has changed.
3905   887A             
3906   887A DD 7E 04    dspr4  ld a,(ix+4)         ; old y.
3907   887D DD BE 09           cp (ix+9)           ; compare with new value.
3908   8880 20 19              jr nz,dspr7         ; they differ, need to redraw.
3909   8882 DD 7E 03           ld a,(ix+3)         ; old x.
3910   8885 DD BE 08           cp (ix+8)           ; compare against new value.
3911   8888 20 11              jr nz,dspr7         ; they differ, need to redraw.
3912   888A DD 7E 02           ld a,(ix+2)         ; old frame.
3913   888D DD BE 07           cp (ix+7)           ; compare against new value.
3914   8890 20 09              jr nz,dspr7         ; they differ, need to redraw.
3915   8892 DD 7E 01           ld a,(ix+1)         ; old image.
3916   8895 DD BE 06           cp (ix+6)           ; compare against new value.
3917   8898 CA 53 88           jp z,dspr2          ; everything is the same, don't redraw.
3918   889B CD 26 89    dspr7  call sspric         ; delete old sprite, draw new one simultaneously.
3919   889E C3 53 88           jp dspr2
3920   88A1 CD 20 89    dspr3  call ssprib         ; show single sprite.
3921   88A4 C3 53 88           jp dspr2
3922   88A7             
3923   88A7             
3924   88A7             ; Get sprite address calculations.
3925   88A7             ; gspran = new sprite, gsprad = old sprite.
3926   88A7             
3927   88A7 DD 6E 08    gspran ld l,(ix+8)         ; new x coordinate.
3928   88AA DD 66 09           ld h,(ix+9)         ; new y coordinate.
3929   88AD 22 5B 77           ld (dispx),hl       ; set display coordinates.
3930   88B0 DD 7E 06           ld a,(ix+6)         ; new sprite image.
3931   88B3 CD BA 8B           call gfrm           ; fetch start frame for this sprite.
3932   88B6 7E                 ld a,(hl)           ; frame in accumulator.
3933   88B7 DD 86 07           add a,(ix+7)        ; new add frame number.
3934   88BA C3 D0 88           jp gspra0
3935   88BD             
3936   88BD DD 6E 03    gsprad ld l,(ix+3)         ; x coordinate.
3937   88C0 DD 66 04           ld h,(ix+4)         ; y coordinate.
3938   88C3 22 5B 77           ld (dispx),hl       ; set display coordinates.
3939   88C6 DD 7E 01           ld a,(ix+1)         ; sprite image.
3940   88C9 CD BA 8B           call gfrm           ; fetch start frame for this sprite.
3941   88CC 7E                 ld a,(hl)           ; frame in accumulator.
3942   88CD DD 86 02           add a,(ix+2)        ; add frame number.
3943   88D0             
3944   88D0 0F          gspra0 rrca                ; multiply by 128.
3945   88D1 57                 ld d,a              ; store in d.
3946   88D2 E6 80              and 128             ; low byte bit.
3947   88D4 5F                 ld e,a              ; got low byte.
3948   88D5 7A                 ld a,d              ; restore result.
3949   88D6 E6 7F              and 127             ; high byte bits.
3950   88D8 57                 ld d,a              ; displacement high byte.
3951   88D9 21 FA 6C           ld hl,sprgfx        ; address of play sprites.
3952   88DC 19                 add hl,de           ; point to frame.
3953   88DD             
3954   88DD 3A 5C 77           ld a,(dispy)        ; y coordinate.
3955   88E0 E6 06              and 6               ; position within byte boundary.
3956   88E2 4F                 ld c,a              ; low byte of table displacement.
3957   88E3 07                 rlca                ; multiply by 32.
3958   88E4 07                 rlca                ; already a multiple
3959   88E5 07                 rlca                ; of 2, so just 4
3960   88E6 07                 rlca                ; shifts needed.
3961   88E7 5F                 ld e,a              ; put displacement in low byte of de.
3962   88E8 16 00              ld d,0              ; zero the high byte.
3963   88EA 42                 ld b,d              ; no high byte for mask displacement either.
3964   88EB 19                 add hl,de           ; add to sprite address.
3965   88EC EB                 ex de,hl            ; need it in de for now.
3966   88ED 21 09 89           ld hl,spmask        ; pointer to mask table.
3967   88F0 09                 add hl,bc           ; add displacement to pointer.
3968   88F1 4E                 ld c,(hl)           ; left mask.
3969   88F2 23                 inc hl
3970   88F3 46                 ld b,(hl)           ; right mask.
3971   88F4             
3972   88F4             ; Drop into screen address routine.
3973   88F4             ; This routine returns a screen address for (dispx, dispy) in hl.
3974   88F4             
3975   88F4 3A 5B 77    scadd  ld a,(dispx)        ; coordinate.
3976   88F7 6F                 ld l,a              ; low byte of table.
3977   88F8 26 FB              ld h,251            ; high byte of 64256 (SCADTB).
3978   88FA 7E                 ld a,(hl)           ; fetch high byte.
3979   88FB 24                 inc h               ; point to low byte table.
3980   88FC 6E                 ld l,(hl)           ; fetch low byte.
3981   88FD 67                 ld h,a              ; hl points to start of line.
3982   88FE 3A 5C 77           ld a,(dispy)        ; y pixel coordinate.
3983   8901 0F                 rrca                ; divide by 8.
3984   8902 0F                 rrca
3985   8903 0F                 rrca
3986   8904 E6 1F              and 31              ; squares 0 - 31 across screen.
3987   8906 85                 add a,l             ; add to address.
3988   8907 6F                 ld l,a              ; copy to hl = address of screen.
3989   8908 C9                 ret
3990   8909             
3991   8909             spmask defb 255,0,63,192,15,240,3,252
3991   8909 FF003FC00FF003FC
3992   8911             
3993   8911             
3994   8911             ; These are the sprite routines.
3995   8911             ; sspria = single sprite, old (ix).
3996   8911             ; ssprib = single sprite, new (ix+5).
3997   8911             ; sspric = both sprites, old (ix) and new (ix+5).
3998   8911             
3999   8911 CD BD 88    sspria call gsprad         ; get old sprite address.
4000   8914 3E 10       sspri2 ld a,16             ; vertical lines.
4001   8916 08          sspri0 ex af,af'           ; store line counter away in alternate registers.
4002   8917 CD A9 89           call dline          ; draw a line.
4003   891A 08                 ex af,af'           ; restore line counter.
4004   891B 3D                 dec a               ; one less to go.
4005   891C C2 16 89           jp nz,sspri0
4006   891F C9                 ret
4007   8920             
4008   8920 CD A7 88    ssprib call gspran         ; get new sprite address.
4009   8923 C3 14 89           jp sspri2
4010   8926             
4011   8926 CD BD 88    sspric call gsprad         ; get old sprite address.
4012   8929 D9                 exx                 ; store addresses.
4013   892A CD A7 88           call gspran         ; get new sprite addresses.
4014   892D CD A9 89           call dline          ; draw a line.
4015   8930 D9                 exx                 ; restore old addresses.
4016   8931 CD A9 89           call dline          ; delete a line.
4017   8934 D9                 exx                 ; flip to new sprite addresses.
4018   8935 CD A9 89           call dline          ; draw a line.
4019   8938 D9                 exx                 ; restore old addresses.
4020   8939 CD A9 89           call dline          ; delete a line.
4021   893C D9                 exx                 ; flip to new sprite addresses.
4022   893D CD A9 89           call dline          ; draw a line.
4023   8940 D9                 exx                 ; restore old addresses.
4024   8941 CD A9 89           call dline          ; delete a line.
4025   8944 D9                 exx                 ; flip to new sprite addresses.
4026   8945 CD A9 89           call dline          ; draw a line.
4027   8948 D9                 exx                 ; restore old addresses.
4028   8949 CD A9 89           call dline          ; delete a line.
4029   894C D9                 exx                 ; flip to new sprite addresses.
4030   894D CD A9 89           call dline          ; draw a line.
4031   8950 D9                 exx                 ; restore old addresses.
4032   8951 CD A9 89           call dline          ; delete a line.
4033   8954 D9                 exx                 ; flip to new sprite addresses.
4034   8955 CD A9 89           call dline          ; draw a line.
4035   8958 D9                 exx                 ; restore old addresses.
4036   8959 CD A9 89           call dline          ; delete a line.
4037   895C D9                 exx                 ; flip to new sprite addresses.
4038   895D CD A9 89           call dline          ; draw a line.
4039   8960 D9                 exx                 ; restore old addresses.
4040   8961 CD A9 89           call dline          ; delete a line.
4041   8964 D9                 exx                 ; flip to new sprite addresses.
4042   8965 CD A9 89           call dline          ; draw a line.
4043   8968 D9                 exx                 ; restore old addresses.
4044   8969 CD A9 89           call dline          ; delete a line.
4045   896C D9                 exx                 ; flip to new sprite addresses.
4046   896D CD A9 89           call dline          ; draw a line.
4047   8970 D9                 exx                 ; restore old addresses.
4048   8971 CD A9 89           call dline          ; delete a line.
4049   8974 D9                 exx                 ; flip to new sprite addresses.
4050   8975 CD A9 89           call dline          ; draw a line.
4051   8978 D9                 exx                 ; restore old addresses.
4052   8979 CD A9 89           call dline          ; delete a line.
4053   897C D9                 exx                 ; flip to new sprite addresses.
4054   897D CD A9 89           call dline          ; draw a line.
4055   8980 D9                 exx                 ; restore old addresses.
4056   8981 CD A9 89           call dline          ; delete a line.
4057   8984 D9                 exx                 ; flip to new sprite addresses.
4058   8985 CD A9 89           call dline          ; draw a line.
4059   8988 D9                 exx                 ; restore old addresses.
4060   8989 CD A9 89           call dline          ; delete a line.
4061   898C D9                 exx                 ; flip to new sprite addresses.
4062   898D CD A9 89           call dline          ; draw a line.
4063   8990 D9                 exx                 ; restore old addresses.
4064   8991 CD A9 89           call dline          ; delete a line.
4065   8994 D9                 exx                 ; flip to new sprite addresses.
4066   8995 CD A9 89           call dline          ; draw a line.
4067   8998 D9                 exx                 ; restore old addresses.
4068   8999 CD A9 89           call dline          ; delete a line.
4069   899C D9                 exx                 ; flip to new sprite addresses.
4070   899D CD A9 89           call dline          ; draw a line.
4071   89A0 D9                 exx                 ; restore old addresses.
4072   89A1 CD A9 89           call dline          ; delete a line.
4073   89A4 D9                 exx                 ; flip to new sprite addresses.
4074   89A5 CD A9 89           call dline          ; draw a line.
4075   89A8 D9                 exx                 ; restore old addresses.
4076   89A9             
4077   89A9             ; Drop through.
4078   89A9             ; Line drawn, now work out next target address.
4079   89A9             
4080   89A9 1A          dline  ld a,(de)           ; graphic data.
4081   89AA A1                 and c               ; mask away what's not needed.
4082   89AB AE                 xor (hl)            ; XOR with what's there.
4083   89AC 77                 ld (hl),a           ; bung it in.
4084   89AD 2C                 inc l               ; next screen address.
4085   89AE 2C                 inc l               ; next screen address.
4086   89AF 1A                 ld a,(de)           ; fetch data.
4087   89B0 A0                 and b               ; mask away unwanted bits.
4088   89B1 AE                 xor (hl)            ; XOR with what's there.
4089   89B2 77                 ld (hl),a           ; bung it in.
4090   89B3 13                 inc de              ; next graphic.
4091   89B4 2D                 dec l               ; one character cell to the left.
4092   89B5 1A                 ld a,(de)           ; second bit of data.
4093   89B6 AE                 xor (hl)            ; XOR with what's there.
4094   89B7 77                 ld (hl),a           ; bung it in.
4095   89B8 13                 inc de              ; point to next line of data.
4096   89B9 2D                 dec l               ; another char left.
4097   89BA             
4098   89BA             ; Line drawn, now work out next target address.
4099   89BA             
4100   89BA 24          nline  inc h               ; increment pixel.
4101   89BB 7C                 ld a,h              ; get pixel address.
4102   89BC E6 07              and 7               ; straddling character position?
4103   89BE C0                 ret nz              ; no, we're on next line already.
4104   89BF 7C                 ld a,h              ; get pixel address.
4105   89C0 D6 08              sub 8               ; subtract 8 for start of segment.
4106   89C2 67                 ld h,a              ; new high byte of address.
4107   89C3 7D                 ld a,l              ; get low byte of address.
4108   89C4 C6 20              add a,32            ; one line down.
4109   89C6 6F                 ld l,a              ; new low byte.
4110   89C7 D0                 ret nc              ; not reached next segment yet.
4111   89C8 7C                 ld a,h              ; address high.
4112   89C9 C6 08              add a,8             ; add 8 to next segment.
4113   89CB 67                 ld h,a              ; new high byte.
4114   89CC FE 58              cp 88               ; reached end of screen?
4115   89CE D8                 ret c               ; not yet.
4116   89CF 26 38              ld h,56             ; back to ROM.
4117   89D1 C9                 ret
4118   89D2             
4119   89D2             
4120   89D2             ; Animates a sprite.
4121   89D2             
4122   89D2 21 2B 77    animsp ld hl,frmno         ; game frame.
4123   89D5 A6                 and (hl)            ; is it time to change the frame?
4124   89D6 C0                 ret nz              ; not this frame.
4125   89D7 DD 7E 06           ld a,(ix+6)         ; sprite image.
4126   89DA CD BA 8B           call gfrm           ; get frame data.
4127   89DD 23                 inc hl              ; point to frames.
4128   89DE DD 7E 07           ld a,(ix+7)         ; sprite frame.
4129   89E1 3C                 inc a               ; next one along.
4130   89E2 BE                 cp (hl)             ; reached the last frame?
4131   89E3 38 01              jr c,anims0         ; no, not yet.
4132   89E5 AF                 xor a               ; start at first frame.
4133   89E6 DD 77 07    anims0 ld (ix+7),a         ; new frame.
4134   89E9 C9                 ret
4135   89EA 21 2B 77    animbk ld hl,frmno         ; game frame.
4136   89ED A6                 and (hl)            ; is it time to change the frame?
4137   89EE C0                 ret nz              ; not this frame.
4138   89EF DD 7E 06           ld a,(ix+6)         ; sprite image.
4139   89F2 CD BA 8B           call gfrm           ; get frame data.
4140   89F5 23                 inc hl              ; point to frames.
4141   89F6 DD 7E 07           ld a,(ix+7)         ; sprite frame.
4142   89F9 A7                 and a               ; first one?
4143   89FA 20 01              jr nz,rtanb0        ; yes, start at end.
4144   89FC 7E                 ld a,(hl)           ; last sprite.
4145   89FD 3D          rtanb0 dec a               ; next one along.
4146   89FE 18 E6              jr anims0           ; set new frame.
4147   8A00             
4148   8A00             ; Check for collision with other sprite, strict enforcement.
4149   8A00             
4150   8A00 21 65 8D    sktyp  ld hl,sprtab        ; sprite table.
4151   8A03 3E 0C       numsp2 ld a,NUMSPR         ; number of sprites.
4152   8A05 08          sktyp0 ex af,af'           ; store loop counter.
4153   8A06 22 21 8A           ld (skptr),hl       ; store pointer to sprite.
4154   8A09 7E                 ld a,(hl)           ; get sprite type.
4155   8A0A B8                 cp b                ; is it the type we seek?
4156   8A0B 28 16              jr z,coltyp         ; yes, we can use this one.
4157   8A0D 2A 21 8A    sktyp1 ld hl,(skptr)       ; retrieve sprite pointer.
4158   8A10 11 11 00           ld de,TABSIZ        ; size of each entry.
4159   8A13 19                 add hl,de           ; point to next sprite in table.
4160   8A14 08                 ex af,af'           ; restore loop counter.
4161   8A15 3D                 dec a               ; one less iteration.
4162   8A16 C2 05 8A           jp nz,sktyp0        ; keep going until we find a slot.
4163   8A19 21 00 00           ld hl,0             ; default to ROM address - no sprite.
4164   8A1C 22 21 8A           ld (skptr),hl       ; store pointer to sprite.
4165   8A1F B4                 or h                ; don't return with zero flag set.
4166   8A20 C9                 ret                 ; didn't find one.
4167   8A21 00 00       skptr  defw 0              ; search pointer.
4168   8A23             
4169   8A23 DD 7E 00    coltyp ld a,(ix+0)         ; current sprite type.
4170   8A26 B8                 cp b                ; seeking sprite of same type?
4171   8A27 28 27              jr z,colty1         ; yes, need to check we're not detecting ourselves.
4172   8A29 11 08 00    colty0 ld de,X             ; distance to x position in table.
4173   8A2C 19                 add hl,de           ; point to coords.
4174   8A2D 5E                 ld e,(hl)           ; fetch x coordinate.
4175   8A2E 23                 inc hl              ; now point to y.
4176   8A2F 56                 ld d,(hl)           ; that's y coordinate.
4177   8A30             
4178   8A30             ; Drop into collision detection.
4179   8A30             
4180   8A30 DD 7E 08    colc16 ld a,(ix+X)         ; x coord.
4181   8A33 93                 sub e               ; subtract x.
4182   8A34 30 02              jr nc,colc1a        ; result is positive.
4183   8A36 ED 44              neg                 ; make negative positive.
4184   8A38 FE 10       colc1a cp 16               ; within x range?
4185   8A3A 30 D1              jr nc,sktyp1        ; no - they've missed.
4186   8A3C 4F                 ld c,a              ; store difference.
4187   8A3D DD 7E 09           ld a,(ix+Y)         ; y coord.
4188   8A40 92                 sub d               ; subtract y.
4189   8A41 30 02              jr nc,colc1b        ; result is positive.
4190   8A43 ED 44              neg                 ; make negative positive.
4191   8A45 FE 10       colc1b cp 16               ; within y range?
4192   8A47 30 C4              jr nc,sktyp1        ; no - they've missed.
4193   8A49 81                 add a,c             ; add x difference.
4194   8A4A FE 1A              cp 26               ; only 5 corner pixels touching?
4195   8A4C D8                 ret c               ; carry set if there's a collision.
4196   8A4D C3 0D 8A           jp sktyp1           ; try next sprite in table.
4197   8A50             
4198   8A50 DD E5       colty1 push ix             ; base sprite address onto stack.
4199   8A52 D1                 pop de              ; pop it into de.
4200   8A53 EB                 ex de,hl            ; flip hl into de.
4201   8A54 ED 52              sbc hl,de           ; compare the two.
4202   8A56 EB                 ex de,hl            ; restore hl.
4203   8A57 28 B4              jr z,sktyp1         ; addresses are identical.
4204   8A59 C3 29 8A           jp colty0
4205   8A5C             
4206   8A5C             ; Display number.
4207   8A5C             
4208   8A5C 01 6D 8A    disply ld bc,displ0        ; display workspace.
4209   8A5F CD 09 7F           call num2ch         ; convert accumulator to string.
4210   8A62 0B          displ1 dec bc              ; back one character.
4211   8A63 0A                 ld a,(bc)           ; fetch digit.
4212   8A64 F6 80              or 128              ; insert end marker.
4213   8A66 02                 ld (bc),a           ; new value.
4214   8A67 21 6D 8A           ld hl,displ0        ; display space.
4215   8A6A C3 C0 86           jp dmsg3            ; display the string.
4216   8A6D 00 00 00 8D displ0 defb 0,0,0,13+128
4217   8A71             
4218   8A71             
4219   8A71             ; Initialise screen.
4220   8A71             
4221   8A71 3A 42 8E    initsc ld a,(roomtb)       ; whereabouts in the map are we?
4222   8A74 CD 7E 8A           call tstsc          ; find displacement.
4223   8A77 FE FF              cp 255              ; is it valid?
4224   8A79 C8                 ret z               ; no, it's rubbish.
4225   8A7A 32 35 77           ld (scno),a         ; store new room number.
4226   8A7D C9                 ret
4227   8A7E             
4228   8A7E             ; Test screen.
4229   8A7E             
4230   8A7E 21 03 61    tstsc  ld hl,mapdat-MAPWID ; start of map data, subtract width for negative.
4231   8A81 47                 ld b,a              ; store room in b for now.
4232   8A82 C6 05              add a,MAPWID        ; add width in case we're negative.
4233   8A84 5F                 ld e,a              ; screen into e.
4234   8A85 16 00              ld d,0              ; zeroise d.
4235   8A87 19                 add hl,de           ; add displacement to map data.
4236   8A88 7E                 ld a,(hl)           ; find room number there.
4237   8A89 C9                 ret
4238   8A8A             
4239   8A8A             ; Screen left.
4240   8A8A             
4241   8A8A 3A 42 8E    scrl   ld a,(roomtb)       ; present room table pointer.
4242   8A8D 3D                 dec a               ; room left.
4243   8A8E CD 7E 8A    scrl0  call tstsc          ; test screen.
4244   8A91 3C                 inc a               ; is there a screen this way?
4245   8A92 C8                 ret z               ; no, return to loop.
4246   8A93 78                 ld a,b              ; restore room displacement.
4247   8A94 32 42 8E           ld (roomtb),a       ; new room table position.
4248   8A97 CD 71 8A    scrl1  call initsc         ; set new screen.
4249   8A9A 21 58 77           ld hl,restfl        ; restart screen flag.
4250   8A9D 36 02              ld (hl),2           ; set it.
4251   8A9F C9                 ret
4252   8AA0 3A 42 8E    scrr   ld a,(roomtb)       ; room table pointer.
4253   8AA3 3C                 inc a               ; room right.
4254   8AA4 18 E8              jr scrl0
4255   8AA6 3A 42 8E    scru   ld a,(roomtb)       ; room table pointer.
4256   8AA9 D6 05              sub MAPWID          ; room up.
4257   8AAB 18 E1              jr scrl0
4258   8AAD 3A 42 8E    scrd   ld a,(roomtb)       ; room table pointer.
4259   8AB0 C6 05              add a,MAPWID        ; room down.
4260   8AB2 18 DA              jr scrl0
4261   8AB4             
4262   8AB4             ; Jump to new screen.
4263   8AB4             
4264   8AB4 21 08 61    nwscr  ld hl,mapdat        ; start of map data.
4265   8AB7 01 00 50           ld bc,256*80        ; zero room count, 80 to search.
4266   8ABA BE          nwscr0 cp (hl)             ; have we found a match for screen?
4267   8ABB 28 05              jr z,nwscr1         ; yes, set new point in map.
4268   8ABD 23                 inc hl              ; next room.
4269   8ABE 0C                 inc c               ; count rooms.
4270   8ABF 10 F9              djnz nwscr0         ; keep looking.
4271   8AC1 C9                 ret
4272   8AC2 79          nwscr1 ld a,c              ; room displacement.
4273   8AC3 32 42 8E           ld (roomtb),a       ; set the map position.
4274   8AC6 18 CF              jr scrl1            ; draw new room.
4275   8AC8             
4276   8AC8             
4277   8AC8             ; Gravity processing.
4278   8AC8             
4279   8AC8 DD 7E 0D    grav   ld a,(ix+13)        ; in-air flag.
4280   8ACB A7                 and a               ; are we in the air?
4281   8ACC C8                 ret z               ; no we are not.
4282   8ACD 3C                 inc a               ; increment it.
4283   8ACE CA 18 8B           jp z,ogrv           ; set to 255, use old gravity.
4284   8AD1 DD 77 0D           ld (ix+13),a        ; write new setting.
4285   8AD4 1F                 rra                 ; every other frame.
4286   8AD5 30 0A              jr nc,grav0         ; don't apply gravity this time.
4287   8AD7 DD 7E 0E           ld a,(ix+14)        ; pixels to move.
4288   8ADA FE 10              cp 16               ; reached maximum?
4289   8ADC 28 03              jr z,grav0          ; yes, continue.
4290   8ADE DD 34 0E           inc (ix+14)         ; slow down ascent/speed up fall.
4291   8AE1 DD 7E 0E    grav0  ld a,(ix+14)        ; get distance to move.
4292   8AE4 CB 2F              sra a               ; divide by 2.
4293   8AE6 A7                 and a               ; any movement required?
4294   8AE7 C8                 ret z               ; no, not this time.
4295   8AE8 FE 80              cp 128              ; is it up or down?
4296   8AEA 30 0C              jr nc,gravu         ; it's up.
4297   8AEC 47          gravd  ld b,a              ; set pixels to move.
4298   8AED CD BB 84    gravd0 call cangd          ; can we go down?
4299   8AF0 20 15              jr nz,gravst        ; can't move down, so stop.
4300   8AF2 DD 34 08           inc (ix+8)          ; adjust new x coord.
4301   8AF5 10 F6              djnz gravd0
4302   8AF7 C9                 ret
4303   8AF8 ED 44       gravu  neg                 ; flip the sign so it's positive.
4304   8AFA 47                 ld b,a              ; set pixels to move.
4305   8AFB CD 98 84    gravu0 call cangu          ; can we go up?
4306   8AFE C2 9F 8B           jp nz,ifalls        ; can't move up, go down next.
4307   8B01 DD 35 08           dec (ix+8)          ; adjust new x coord.
4308   8B04 10 F5              djnz gravu0
4309   8B06 C9                 ret
4310   8B07 DD 7E 0E    gravst ld a,(ix+14)        ; jump pointer high.
4311   8B0A DD 36 0D 00        ld (ix+13),0        ; reset falling flag.
4312   8B0E DD 36 0E 00        ld (ix+14),0        ; store new speed.
4313   8B12 FE 08              cp 8                ; was speed the maximum?
4314   8B14 CA 18 66    evftf  jp z,evnt15         ; yes, fallen too far.
4315   8B17 C9                 ret
4316   8B18             
4317   8B18             ; Old gravity processing for compatibility with 4.6 and 4.7.
4318   8B18             
4319   8B18 DD 5E 0E    ogrv   ld e,(ix+14)        ; get index to table.
4320   8B1B 16 00              ld d,0              ; no high byte.
4321   8B1D 21 B1 76           ld hl,jtab          ; jump table.
4322   8B20 19                 add hl,de           ; hl points to jump value.
4323   8B21 7E                 ld a,(hl)           ; pixels to move.
4324   8B22 FE 63              cp 99               ; reached the end?
4325   8B24 20 04              jr nz,ogrv0         ; no, continue.
4326   8B26 2B                 dec hl              ; go back to previous value.
4327   8B27 7E                 ld a,(hl)           ; fetch that from table.
4328   8B28 18 03              jr ogrv1
4329   8B2A DD 34 0E    ogrv0  inc (ix+14)         ; point to next table entry.
4330   8B2D A7          ogrv1  and a               ; any movement required?
4331   8B2E C8                 ret z               ; no, not this time.
4332   8B2F FE 80              cp 128              ; is it up or down?
4333   8B31 30 0C              jr nc,ogrvu         ; it's up.
4334   8B33 47          ogrvd  ld b,a              ; set pixels to move.
4335   8B34 CD BB 84    ogrvd0 call cangd          ; can we go down?
4336   8B37 20 14              jr nz,ogrvst        ; can't move down, so stop.
4337   8B39 DD 34 08           inc (ix+8)          ; adjust new x coord.
4338   8B3C 10 F6              djnz ogrvd0
4339   8B3E C9                 ret
4340   8B3F ED 44       ogrvu  neg                 ; flip the sign so it's positive.
4341   8B41 47                 ld b,a              ; set pixels to move.
4342   8B42 CD 98 84    ogrvu0 call cangu          ; can we go up?
4343   8B45 20 1D              jr nz,ogrv2         ; can't move up, go down next.
4344   8B47 DD 35 08           dec (ix+8)          ; adjust new x coord.
4345   8B4A 10 F6              djnz ogrvu0
4346   8B4C C9                 ret
4347   8B4D DD 5E 0E    ogrvst ld e,(ix+14)        ; get index to table.
4348   8B50 16 00              ld d,0              ; no high byte.
4349   8B52 21 B1 76           ld hl,jtab          ; jump table.
4350   8B55 19                 add hl,de           ; hl points to jump value.
4351   8B56 7E                 ld a,(hl)           ; fetch byte from table.
4352   8B57 FE 63              cp 99               ; is it the end marker?
4353   8B59 DD 36 0D 00        ld (ix+13),0        ; reset jump flag.
4354   8B5D DD 36 0E 00        ld (ix+14),0        ; reset pointer.
4355   8B61 C3 14 8B           jp evftf
4356   8B64 21 B1 76    ogrv2  ld hl,jtab          ; jump table.
4357   8B67 06 00              ld b,0              ; offset into table.
4358   8B69 7E          ogrv4  ld a,(hl)           ; fetch table byte.
4359   8B6A FE 64              cp 100              ; hit end or downward move?
4360   8B6C 38 04              jr c,ogrv3          ; yes.
4361   8B6E 23                 inc hl              ; next byte of table.
4362   8B6F 04                 inc b               ; next offset.
4363   8B70 18 F7              jr ogrv4            ; keep going until we find crest/end of table.
4364   8B72 DD 70 0E    ogrv3  ld (ix+14),b        ; set next table offset.
4365   8B75 C9                 ret
4366   8B76             
4367   8B76             ; Initiate fall check.
4368   8B76             
4369   8B76 DD 7E 0D    ifall  ld a,(ix+13)        ; jump pointer flag.
4370   8B79 A7                 and a               ; are we in the air?
4371   8B7A C0                 ret nz              ; if set, we're already in the air.
4372   8B7B DD 66 09           ld h,(ix+9)         ; y coordinate.
4373   8B7E 3E 10              ld a,16             ; look down 16 pixels.
4374   8B80 DD 86 08           add a,(ix+8)        ; add x coordinate.
4375   8B83 6F                 ld l,a              ; coords in hl.
4376   8B84 22 5B 77           ld (dispx),hl       ; set up test coordinates.
4377   8B87 CD E7 85           call tstbl          ; get map address.
4378   8B8A CD 19 85           call plchk          ; block, platform check.
4379   8B8D C0                 ret nz              ; it's solid, don't fall.
4380   8B8E 23                 inc hl              ; look right one cell.
4381   8B8F CD 19 85           call plchk          ; block, platform check.
4382   8B92 C0                 ret nz              ; it's solid, don't fall.
4383   8B93 3A 5C 77           ld a,(dispy)        ; y coordinate.
4384   8B96 E6 07              and 7               ; position straddling block cells.
4385   8B98 28 05              jr z,ifalls         ; no more checks needed.
4386   8B9A 23                 inc hl              ; look to third cell.
4387   8B9B CD 19 85           call plchk          ; block, platform check.
4388   8B9E C0                 ret nz              ; it's solid, don't fall.
4389   8B9F DD 34 0D    ifalls inc (ix+13)         ; set in air flag.
4390   8BA2 DD 36 0E 00        ld (ix+14),0        ; initial speed = 0.
4391   8BA6 C9                 ret
4392   8BA7 DD 7E 0D    tfall  ld a,(ix+13)        ; jump pointer flag.
4393   8BAA A7                 and a               ; are we in the air?
4394   8BAB C0                 ret nz              ; if set, we're already in the air.
4395   8BAC CD 76 8B           call ifall          ; do fall test.
4396   8BAF DD 7E 0D           ld a,(ix+13)        ; get falling flag.
4397   8BB2 A7                 and a               ; is it set?
4398   8BB3 C8                 ret z               ; no.
4399   8BB4 DD 36 0D FF        ld (ix+13),255      ; we're using the table.
4400   8BB8 18 AA              jr ogrv2            ; find position in table.
4401   8BBA             
4402   8BBA             
4403   8BBA             ; Get frame data for a particular sprite.
4404   8BBA             
4405   8BBA 07          gfrm   rlca                ; multiple of 2.
4406   8BBB 5F                 ld e,a              ; copy to de.
4407   8BBC 16 00              ld d,0              ; no high byte as max sprite is 128.
4408   8BBE 2A 5D 77           ld hl,(frmptr)      ; frames used by game.
4409   8BC1 19                 add hl,de           ; point to frame start.
4410   8BC2 C9                 ret
4411   8BC3             
4412   8BC3             ; Find sprite list for current room.
4413   8BC3             
4414   8BC3 3A 35 77    sprlst ld a,(scno)         ; screen number.
4415   8BC6 2A 67 77    sprls2 ld hl,(nmeptr)      ; pointer to enemies.
4416   8BC9 47                 ld b,a              ; loop counter in b register.
4417   8BCA A7                 and a               ; is it the first screen?
4418   8BCB C8                 ret z               ; yes, don't need to search data.
4419   8BCC 11 04 00           ld de,NMESIZ        ; bytes to skip.
4420   8BCF 7E          sprls1 ld a,(hl)           ; fetch type of sprite.
4421   8BD0 3C                 inc a               ; is it an end marker?
4422   8BD1 28 03              jr z,sprls0         ; yes, end of this room.
4423   8BD3 19                 add hl,de           ; point to next sprite in list.
4424   8BD4 18 F9              jr sprls1           ; continue until end of room.
4425   8BD6 23          sprls0 inc hl              ; point to start of next screen.
4426   8BD7 10 F6              djnz sprls1         ; continue until room found.
4427   8BD9 C9                 ret
4428   8BDA             
4429   8BDA             
4430   8BDA             ; Clear all but a single player sprite.
4431   8BDA             
4432   8BDA 06 0C       nspr   ld b,NUMSPR         ; sprite slots in table.
4433   8BDC DD 21 65 8D        ld ix,sprtab        ; sprite table.
4434   8BE0 11 11 00           ld de,TABSIZ        ; distance to next odd/even entry.
4435   8BE3 DD 7E 00    nspr0  ld a,(ix+0)         ; fetch sprite type.
4436   8BE6 A7                 and a               ; is it a player?
4437   8BE7 28 0D              jr z,nspr1          ; yes, keep this one.
4438   8BE9 DD 36 00 FF        ld (ix+0),255       ; delete sprite.
4439   8BED DD 36 05 FF        ld (ix+5),255       ; remove next type.
4440   8BF1 DD 19              add ix,de           ; next sprite.
4441   8BF3 10 EE              djnz nspr0          ; one less space in the table.
4442   8BF5 C9                 ret
4443   8BF6 DD 36 00 FF nspr1  ld (ix+0),255       ; delete sprite.
4444   8BFA DD 19              add ix,de           ; point to next sprite.
4445   8BFC 10 01              djnz nspr2          ; one less to do.
4446   8BFE C9                 ret
4447   8BFF DD 36 00 FF nspr2  ld (ix+0),255       ; delete sprite.
4448   8C03 DD 36 05 FF        ld (ix+5),255       ; remove next type.
4449   8C07 DD 19              add ix,de           ; next sprite.
4450   8C09 10 F4              djnz nspr2          ; one less space in the table.
4451   8C0B C9                 ret
4452   8C0C             
4453   8C0C             
4454   8C0C             ; Two initialisation routines.
4455   8C0C             ; Initialise sprites - copy everything from list to table.
4456   8C0C             
4457   8C0C 06 0C       ispr   ld b,NUMSPR         ; sprite slots in table.
4458   8C0E DD 21 65 8D        ld ix,sprtab        ; sprite table.
4459   8C12 7E          ispr2  ld a,(hl)           ; fetch byte.
4460   8C13 FE FF              cp 255              ; is it an end marker?
4461   8C15 C8                 ret z               ; yes, no more to do.
4462   8C16 DD 7E 00    ispr1  ld a,(ix+0)         ; fetch sprite type.
4463   8C19 FE FF              cp 255              ; is it enabled yet?
4464   8C1B 20 07              jr nz,ispr4         ; yes, try another slot.
4465   8C1D DD 7E 05           ld a,(ix+5)         ; next type.
4466   8C20 FE FF              cp 255              ; is it enabled yet?
4467   8C22 28 08              jr z,ispr3          ; no, process this one.
4468   8C24 11 11 00    ispr4  ld de,TABSIZ        ; distance to next odd/even entry.
4469   8C27 DD 19              add ix,de           ; next sprite.
4470   8C29 10 EB              djnz ispr1          ; repeat for remaining sprites.
4471   8C2B C9                 ret                 ; no more room in table.
4472   8C2C CD 61 8C    ispr3  call cpsp           ; initialise a sprite.
4473   8C2F 10 E1              djnz ispr2          ; one less space in the table.
4474   8C31 C9                 ret
4475   8C32             
4476   8C32             ; Initialise sprites - but not player, we're keeping the old one.
4477   8C32             
4478   8C32 06 0C       kspr   ld b,NUMSPR         ; sprite slots in table.
4479   8C34 DD 21 65 8D        ld ix,sprtab        ; sprite table.
4480   8C38 7E          kspr2  ld a,(hl)           ; fetch byte.
4481   8C39 FE FF              cp 255              ; is it an end marker?
4482   8C3B C8                 ret z               ; yes, no more to do.
4483   8C3C A7                 and a               ; is it a player sprite?
4484   8C3D 20 06              jr nz,kspr1         ; no, add to table as normal.
4485   8C3F 11 04 00           ld de,NMESIZ        ; distance to next item in list.
4486   8C42 19                 add hl,de           ; point to next one.
4487   8C43 18 F3              jr kspr2
4488   8C45 DD 7E 00    kspr1  ld a,(ix+0)         ; fetch sprite type.
4489   8C48 FE FF              cp 255              ; is it enabled yet?
4490   8C4A 20 07              jr nz,kspr4         ; yes, try another slot.
4491   8C4C DD 7E 05           ld a,(ix+5)         ; next type.
4492   8C4F FE FF              cp 255              ; is it enabled yet?
4493   8C51 28 08              jr z,kspr3          ; no, process this one.
4494   8C53 11 11 00    kspr4  ld de,TABSIZ        ; distance to next odd/even entry.
4495   8C56 DD 19              add ix,de           ; next sprite.
4496   8C58 10 EB              djnz kspr1          ; repeat for remaining sprites.
4497   8C5A C9                 ret                 ; no more room in table.
4498   8C5B CD 61 8C    kspr3  call cpsp           ; copy sprite to table.
4499   8C5E 10 D8              djnz kspr2          ; one less space in the table.
4500   8C60 C9                 ret
4501   8C61             
4502   8C61             ; Copy sprite from list to table.
4503   8C61             
4504   8C61 7E          cpsp   ld a,(hl)           ; fetch byte from table.
4505   8C62 DD 77 00           ld (ix+0),a         ; set up type.
4506   8C65 DD 77 05           ld (ix+PAM1ST),a    ; set up type.
4507   8C68 23                 inc hl              ; move to next byte.
4508   8C69 7E                 ld a,(hl)           ; fetch byte from table.
4509   8C6A DD 77 06           ld (ix+6),a         ; set up image.
4510   8C6D 23                 inc hl              ; move to next byte.
4511   8C6E 7E                 ld a,(hl)           ; fetch byte from table.
4512   8C6F DD 36 03 C8        ld (ix+3),200       ; set initial coordinate off screen.
4513   8C73 DD 77 08           ld (ix+8),a         ; set up coordinate.
4514   8C76 23                 inc hl              ; move to next byte.
4515   8C77 7E                 ld a,(hl)           ; fetch byte from table.
4516   8C78 DD 77 09           ld (ix+9),a         ; set up coordinate.
4517   8C7B 23                 inc hl              ; move to next byte.
4518   8C7C AF                 xor a               ; zeroes in accumulator.
4519   8C7D DD 77 07           ld (ix+7),a         ; reset frame number.
4520   8C80 DD 77 0A           ld (ix+10),a        ; reset direction.
4521   8C83             ;       ld (ix+12),a        ; reset parameter B.
4522   8C83 DD 77 0D           ld (ix+13),a        ; reset jump pointer low.
4523   8C86 DD 77 0E           ld (ix+14),a        ; reset jump pointer high.
4524   8C89 DD 36 10 FF        ld (ix+16),255      ; reset data pointer to auto-restore.
4525   8C8D DD E5              push ix             ; store ix pair.
4526   8C8F E5                 push hl             ; store hl pair.
4527   8C90 C5                 push bc
4528   8C91 CD FB 63    evis0  call evnt09         ; perform event.
4529   8C94 C1                 pop bc
4530   8C95 E1                 pop hl              ; restore hl.
4531   8C96 DD E1              pop ix              ; restore ix.
4532   8C98 11 11 00           ld de,TABSIZ        ; distance to next odd/even entry.
4533   8C9B DD 19              add ix,de           ; next sprite.
4534   8C9D C9                 ret
4535   8C9E             
4536   8C9E             ; Clear the play area window.
4537   8C9E             
4538   8C9E 2A 2C 77    clw    ld hl,(wintop)      ; get coordinates of window.
4539   8CA1 22 5B 77           ld (dispx),hl       ; put into dispx for calculation.
4540   8CA4 3A 2E 77           ld a,(winhgt)       ; height of window.
4541   8CA7 47                 ld b,a              ; copy to b register.
4542   8CA8 C5          clw3   push bc             ; store lines on stack.
4543   8CA9 3A 2F 77           ld a,(winwid)       ; width of window.
4544   8CAC 08          clw2   ex af,af'           ; store column counter.
4545   8CAD CD E0 82           call gprad          ; get print address.
4546   8CB0 AF                 xor a               ; zero byute to write.
4547   8CB1 06 08              ld b,8              ; pixel height of each cell.
4548   8CB3 12          clw1   ld (de),a           ; copy to screen.
4549   8CB4 14                 inc d               ; next screen row down.
4550   8CB5 10 FC              djnz clw1
4551   8CB7 CD 0E 83           call gaadd          ; get attribute address.
4552   8CBA 3A 8D 5C           ld a,(23693)        ; get colour.
4553   8CBD 77                 ld (hl),a           ; write colour.
4554   8CBE 21 5C 77           ld hl,dispy         ; column position.
4555   8CC1 34                 inc (hl)            ; next column.
4556   8CC2 08                 ex af,af'           ; restore column counter.
4557   8CC3 3D                 dec a               ; one less to do.
4558   8CC4 20 E6              jr nz,clw2          ; repeat for remaining columns.
4559   8CC6 3A 2D 77           ld a,(winlft)       ; get left edge.
4560   8CC9 32 5C 77           ld (dispy),a        ; reset y.
4561   8CCC 21 5B 77           ld hl,dispx         ; line.
4562   8CCF 34                 inc (hl)            ; next line down.
4563   8CD0 C1                 pop bc              ; restore line counter.
4564   8CD1 10 D5              djnz clw3           ; repeat down the screen.
4565   8CD3 2A 2C 77           ld hl,(wintop)      ; get coordinates of window.
4566   8CD6 22 50 77           ld (charx),hl       ; put into display position.
4567   8CD9 C9                 ret
4568   8CDA             
4569   8CDA             ; Effects code.
4570   8CDA             ; Ticker routine is called 25 times per second.
4571   8CDA             
4572   8CDA C9          scrly  ret
4573   8CDB ED 7A              defw txtscr         ; get screen address.
4574   8CDD 06 08              ld b,8              ; 8 pixel rows.
4575   8CDF E5                 push hl             ; store screen address.
4576   8CE0 C5          scrly1 push bc             ; store rows on stack.
4577   8CE1 E5                 push hl
4578   8CE2 3A E8 7A           ld a,(txtwid)       ; characters wide.
4579   8CE5 47                 ld b,a              ; put into the loop counter.
4580   8CE6 A7                 and a               ; reset carry flag.
4581   8CE7 CB 16       scrly0 rl (hl)             ; rotate left.
4582   8CE9 2D                 dec l               ; char left.
4583   8CEA 10 FB              djnz scrly0         ; repeat for width of ticker message.
4584   8CEC E1                 pop hl
4585   8CED 24                 inc h               ; next row down.
4586   8CEE C1                 pop bc              ; retrieve row counter from stack.
4587   8CEF 10 EF              djnz scrly1         ; repeat for all rows.
4588   8CF1 2A E9 7A           ld hl,(txtpos)      ; get text pointer.
4589   8CF4 7E                 ld a,(hl)           ; find character we're displaying.
4590   8CF5 E6 7F              and 127             ; remove end marker bit if applicable.
4591   8CF7 FE 0D              cp 13               ; is it newline?
4592   8CF9 20 02              jr nz,scrly5        ; no, it's okay.
4593   8CFB 3E 20              ld a,32             ; convert to a space instead.
4594   8CFD 07          scrly5 rlca
4595   8CFE 07                 rlca
4596   8CFF 07                 rlca                ; multiply by 8 to find char.
4597   8D00 47                 ld b,a              ; store shift in b.
4598   8D01 E6 03              and 3               ; keep within 768-byte range of font.
4599   8D03 57                 ld d,a              ; that's our high byte.
4600   8D04 78                 ld a,b              ; restore the shift.
4601   8D05 E6 F8              and 248
4602   8D07 5F                 ld e,a
4603   8D08 2A 36 5C           ld hl,(23606)       ; font address.
4604   8D0B 19                 add hl,de           ; point to image of character.
4605   8D0C EB                 ex de,hl            ; need the address in de.
4606   8D0D E1                 pop hl
4607   8D0E             
4608   8D0E 3A E7 7A           ld a,(txtbit)
4609   8D11 4F                 ld c,a
4610   8D12 06 08              ld b,8
4611   8D14 1A          scrly3 ld a,(de)           ; get image of char line.
4612   8D15 A1                 and c               ; test relevant bit of char.
4613   8D16 28 01              jr z,scrly2         ; not set - skip.
4614   8D18 34                 inc (hl)            ; set bit.
4615   8D19 24          scrly2 inc h               ; next line of window.
4616   8D1A 13                 inc de              ; next line of char.
4617   8D1B 10 F7              djnz scrly3
4618   8D1D 21 E7 7A           ld hl,txtbit        ; bit of text to display.
4619   8D20 CB 0E              rrc (hl)            ; next bit of char to use.
4620   8D22 D0                 ret nc              ; not reached end of character yet.
4621   8D23 2A E9 7A           ld hl,(txtpos)      ; text pointer.
4622   8D26 7E                 ld a,(hl)           ; what was the character?
4623   8D27 23                 inc hl              ; next character in message.
4624   8D28 17                 rla                 ; end of message?
4625   8D29             ;       ret nc              ; not yet, exit here.
4626   8D29             ;       ld a,201            ; code for ret.
4627   8D29             ;       ld (scrly),a        ; disable scrolling routine.
4628   8D29 30 03              jr nc,scrly6        ; not yet - continue.
4629   8D2B 2A EB 7A    scrly4 ld hl,(txtini)      ; start of scrolling message.
4630   8D2E 22 E9 7A    scrly6 ld (txtpos),hl      ; new text pointer position.
4631   8D31 C9                 ret
4632   8D32             
4633   8D32 CD 9B 87    iscrly call prescr         ; set up display position.
4634   8D35 21 91 66           ld hl,msgdat        ; text messages.
4635   8D38 78                 ld a,b              ; width.
4636   8D39 3D                 dec a               ; subtract one.
4637   8D3A FE 20              cp 32               ; is it between 1 and 32?
4638   8D3C 30 0B              jr nc,iscrl0        ; no, disable messages.
4639   8D3E 79                 ld a,c              ; message number.
4640   8D3F 50                 ld d,b              ; copy width to d.
4641   8D40 CD A4 87           call getwrd         ; find message start.
4642   8D43 42                 ld b,d              ; restore width to b register.
4643   8D44 22 EB 7A           ld (txtini),hl      ; set initial text position.
4644   8D47 3E 2A              ld a,42             ; code for ld hl,(nn).
4645   8D49 32 DA 8C    iscrl0 ld (scrly),a        ; enable/disable scrolling routine.
4646   8D4C CD 9B 87           call prescr         ; set up display position.
4647   8D4F CD E0 82           call gprad          ; get print address.
4648   8D52 68                 ld l,b              ; width in b so copy to hl.
4649   8D53 26 00              ld h,0              ; no high byte.
4650   8D55 2B                 dec hl              ; width minus one.
4651   8D56 19                 add hl,de           ; add width.
4652   8D57 22 ED 7A           ld (txtscr),hl      ; set text screen address.
4653   8D5A 78                 ld a,b              ; width.
4654   8D5B 32 E8 7A           ld (txtwid),a       ; set width in working storage.
4655   8D5E 21 E7 7A           ld hl,txtbit        ; bit of text to display.
4656   8D61 36 80              ld (hl),128         ; start with leftmost bit.
4657   8D63 18 C6              jr scrly4
4658   8D65             
4659   8D65             ; Sprite table.
4660   8D65             ; ix+0  = type.
4661   8D65             ; ix+1  = sprite image number.
4662   8D65             ; ix+2  = frame.
4663   8D65             ; ix+3  = x coord.
4664   8D65             ; ix+4  = y coord.
4665   8D65             
4666   8D65             ; ix+5  = new type.
4667   8D65             ; ix+6  = new image number.
4668   8D65             ; ix+7  = new frame.
4669   8D65             ; ix+8  = new x coord.
4670   8D65             ; ix+9  = new y coord.
4671   8D65             
4672   8D65             ; ix+10 = direction.
4673   8D65             ; ix+11 = parameter 1.
4674   8D65             ; ix+12 = parameter 2.
4675   8D65             ; ix+13 = jump pointer low.
4676   8D65             ; ix+14 = jump pointer high.
4677   8D65             ; ix+15 = data pointer low.
4678   8D65             ; ix+16 = data pointer high.
4679   8D65             
4680   8D65             
4681   8D65             sprtab equ $
4682   8D65             
4683   8D65             ;       block NUMSPR * TABSIZ,255
4684   8D65             
4685   8D65                    defb 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255
4685   8D65 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
4686   8D76                    defb 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255
4686   8D76 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
4687   8D87                    defb 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255
4687   8D87 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
4688   8D98                    defb 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255
4688   8D98 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
4689   8DA9                    defb 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255
4689   8DA9 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
4690   8DBA                    defb 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255
4690   8DBA FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
4691   8DCB                    defb 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255
4691   8DCB FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
4692   8DDC                    defb 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255
4692   8DDC FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
4693   8DED                    defb 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255
4693   8DED FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
4694   8DFE                    defb 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255
4694   8DFE FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
4695   8E0F                    defb 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255
4695   8E0F FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
4696   8E20                    defb 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255
4696   8E20 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
4697   8E31             ssprit defb 255,255,255,255,255,255,255,0,192,120,0,0,0,255,255,255,255
4697   8E31 FFFFFFFFFFFFFF00C078000000FFFFFFFF
4698   8E42             
4699   8E42 22          roomtb defb 34                     ; room number.
4700   8E43             
4701   8E43             ; Everything below here will be generated by the editors.
4702   8E43             
4703   8E43             ; Sounds.
4704   8E43             
4705   8E43 8F          fx1    defb 128+15         ; volume and mixer.
4706   8E44 1F                 defb 31             ; white noise.
4707   8E45 E8 03              defw 1000           ; tone register.
4708   8E47 8F                 defb 128+15         ; volume and mixer.
4709   8E48 19                 defb 25             ; white noise.
4710   8E49 E8 03              defw 1000           ; tone register.
4711   8E4B 8E                 defb 128+14         ; volume and mixer.
4712   8E4C 13                 defb 19             ; white noise.
4713   8E4D E8 03              defw 1000           ; tone register.
4714   8E4F 8D                 defb 128+13         ; volume and mixer.
4715   8E50 0D                 defb 13             ; white noise.
4716   8E51 E8 03              defw 1000           ; tone register.
4717   8E53 8C                 defb 128+12         ; volume and mixer.
4718   8E54 07                 defb 7              ; white noise.
4719   8E55 E8 03              defw 1000           ; tone register.
4720   8E57 8B                 defb 128+11         ; volume and mixer.
4721   8E58 00                 defb 0              ; white noise.
4722   8E59 E8 03              defw 1000           ; tone register.
4723   8E5B 8A                 defb 128+10         ; volume and mixer.
4724   8E5C 06                 defb 6              ; white noise.
4725   8E5D E8 03              defw 1000           ; tone register.
4726   8E5F 88                 defb 128+8          ; volume and mixer.
4727   8E60 0C                 defb 12             ; white noise.
4728   8E61 E8 03              defw 1000           ; tone register.
4729   8E63 86                 defb 128+6          ; volume and mixer.
4730   8E64 12                 defb 18             ; white noise.
4731   8E65 E8 03              defw 1000           ; tone register.
4732   8E67 83                 defb 128+3          ; volume and mixer.
4733   8E68 18                 defb 24             ; white noise.
4734   8E69 E8 03              defw 1000           ; tone register.
4735   8E6B FF                 defb 255
4736   8E6C             
4737   8E6C 4F          fx2    defb 064+15         ; volume and mixer.
4738   8E6D 1B                 defb 27             ; white noise.
4739   8E6E E8 03              defw 1000           ; tone register.
4740   8E70 4E                 defb 064+14         ; volume and mixer.
4741   8E71 1F                 defb 31             ; white noise.
4742   8E72 D0 07              defw 2000           ; tone register.
4743   8E74 4D                 defb 064+13         ; volume and mixer.
4744   8E75 1C                 defb 28             ; white noise.
4745   8E76 B8 0B              defw 3000           ; tone register.
4746   8E78 4C                 defb 064+12         ; volume and mixer.
4747   8E79 1F                 defb 31             ; white noise.
4748   8E7A D0 07              defw 2000           ; tone register.
4749   8E7C 4B                 defb 064+11         ; volume and mixer.
4750   8E7D 1D                 defb 29             ; white noise.
4751   8E7E E8 03              defw 1000           ; tone register.
4752   8E80 4A                 defb 064+10         ; volume and mixer.
4753   8E81 1F                 defb 31             ; white noise.
4754   8E82 D0 07              defw 2000           ; tone register.
4755   8E84 49                 defb 064+9          ; volume and mixer.
4756   8E85 1E                 defb 30             ; white noise.
4757   8E86 B8 0B              defw 3000           ; tone register.
4758   8E88 48                 defb 064+8          ; volume and mixer.
4759   8E89 1F                 defb 31             ; white noise.
4760   8E8A D0 07              defw 2000           ; tone register.
4761   8E8C 47                 defb 064+7          ; volume and mixer.
4762   8E8D 1F                 defb 31             ; white noise.
4763   8E8E E8 03              defw 1000           ; tone register.
4764   8E90 46                 defb 064+6          ; volume and mixer.
4765   8E91 1F                 defb 31             ; white noise.
4766   8E92 D0 07              defw 2000           ; tone register.
4767   8E94 FF                 defb 255
4768   8E95             
4769   8E95 4F          fx3    defb 064+15         ; volume and mixer.
4770   8E96 00                 defb 0              ; white noise.
4771   8E97 A0 0F              defw 4000           ; tone register.
4772   8E99 4F                 defb 064+15         ; volume and mixer.
4773   8E9A 00                 defb 0              ; white noise.
4774   8E9B 04 10              defw 4100           ; tone register.
4775   8E9D 4E                 defb 064+14         ; volume and mixer.
4776   8E9E 00                 defb 0              ; white noise.
4777   8E9F 68 10              defw 4200           ; tone register.
4778   8EA1 4E                 defb 064+14         ; volume and mixer.
4779   8EA2 00                 defb 0              ; white noise.
4780   8EA3 CC 10              defw 4300           ; tone register.
4781   8EA5 4D                 defb 064+13         ; volume and mixer.
4782   8EA6 00                 defb 0              ; white noise.
4783   8EA7 30 11              defw 4400           ; tone register.
4784   8EA9 4D                 defb 064+13         ; volume and mixer.
4785   8EAA 00                 defb 0              ; white noise.
4786   8EAB 94 11              defw 4500           ; tone register.
4787   8EAD 4C                 defb 064+12         ; volume and mixer.
4788   8EAE 00                 defb 0              ; white noise.
4789   8EAF F8 11              defw 4600           ; tone register.
4790   8EB1 4C                 defb 064+12         ; volume and mixer.
4791   8EB2 00                 defb 0              ; white noise.
4792   8EB3 5C 12              defw 4700           ; tone register.
4793   8EB5 4B                 defb 064+11         ; volume and mixer.
4794   8EB6 00                 defb 0              ; white noise.
4795   8EB7 C0 12              defw 4800           ; tone register.
4796   8EB9 4A                 defb 064+10         ; volume and mixer.
4797   8EBA 00                 defb 0              ; white noise.
4798   8EBB 24 13              defw 4900           ; tone register.
4799   8EBD FF                 defb 255
4800   8EBE             
4801   8EBE 63                 defb 99             ; temporary marker.
4802   8EBF             
4803   8EBF                    include "user.asm"
0001+  8EBF C9          user   ret
0002+  8EC0             
4804   8EC0             
4805   8EC0 C9          plsnd  ret
4806   8EC1             DEBUG  equ mloop
4807   8EC1 C3 71 8A    ibloc  jp initsc
4808   8EC4 C9          rbloc  ret
4809   8EC5             eop    equ $
4810   8EC5             
4811   8EC5             	savetap "test.tap",start
4812   8EC5             
